GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#751 Post by vovchik »

Dear SFR,

Many thanks, but it doesn't seem to be a gtkdialog problem. I am using thunor's latest - compiled on my machine:

Code: Select all

gtkdialog version 0.8.4 r503M
And I have all the other dependencies: bc, rsvg*. And my bash is relatively new. And everything works except for interference.sh. I am scratching my head a bit, but something will occur to me eventually. I had a similar problem in programming a chess front end a few days ago. I dimensioned two arrays from 0 to 15 to hold chess figures and, in my stupidity, wrote DECLARE xx[15], yy[15]. After hours scouring the code, it occurred to me that the arrays should be [16] in size, with indexes starting at 0 :(

With kind regards,
vovchik

PS. I am using Lucid - but very modified...upgraded and enhanced

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#752 Post by vovchik »

Dear SFR,

Here are two BaCon versions of your very nice cube demo. I had to modify the bacon source because of nesting limitations in one of my versions, but both attached binaries will run just fine. And the mod to BaCon is pretty trivial and explained in the source. There is very little CPU use.

Thanks for the great stuff.

With kind regards,
vovchik
Attachments
vector_cube.tar.gz
(39.16 KiB) Downloaded 511 times

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#753 Post by SFR »

Cool, thanks! :)
Precalculating sin/cos tables is instant now.

BTW, have you found out what's wrong with interference, because I tried it in Lupu (VBox) and works ok for me. :?

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#754 Post by thunor »

@SFR

Is there a gtkdialog version of your cube demo?

I'm just committing your programs now and I was seeing if there were any more.

Regards,
Thunor

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#755 Post by SFR »

Hey Thunor

Yes, a few post above, in attached tgz (I just re-uploaded it again, because vector.sh was creating some tempfiles in / instead of /dev/shm/.... Corrected now.)
http://murga-linux.com/puppy/viewtopic. ... 355#694355

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#756 Post by vovchik »

Dear SFR,

I managed in BaCon to eliminate all disk reads and writes for your examples, which is hard to do with bash because you can't just call librsvg or gtk_image_set_from_pixbuf directly. :(

Works nicely and is modest in terms of CPU use.

With kind regards,
vovchik
Attachments
wavy-inline.tar.gz
(44.34 KiB) Downloaded 504 times

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#757 Post by SFR »

Hey Vovchik

I tried to re-compile both sources and got:

Code: Select all

# bacon bmrw-inline.bac 
Converting 'bmrw-inline.bac'... done.
Compiling 'bmrw-inline.bac'... Compiler emits messages!
#
hug.bac is in place already, so I guess I also need to pass some additional argument(s)..?
Any tip? :wink:

Thanks & Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#758 Post by vovchik »

Dear SFR,

I used the latest bacon 2.0 - released on 1 April - and the latest HUG 0.84. They are both available at http://www.basic-converter.org/. I just recompiled and everything works fine. I take it you have librsvg, since it's needed to transform the svgs into pixbufs. Thunor could, if he wished, make gtk_image_set_from_pixbuf available in gtkdialog, but then he would have to contend with an additional dependent functions in libsrvg, which is probably a bad idea.

If you are using the latest BaCon and latest HUG, the thing should compile without any errors. :)

With kind regards,
vovchik


PS. I used GTK2. I don't know how all of this would work with GTK3.

PPS. My compile line is:

Code: Select all

bacon -o -s -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections "$myfile"

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#759 Post by SFR »

Oh yes, so probably BaCon version 1.0 build 29 is the cause.
I'll try later with the latest version.
But both binaries work fine. :)

EDIT: Yep, 2.0 did the job indeed - it's all right now.

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#760 Post by vovchik »

Dear SFR,

I have done some nice spirals here: http://basic-converter.proboards.com/in ... 314&page=5. You might be "inspired" to see whether you can get them to work in gtkdialog. The only problem may be the refresh speed, but I think it should be OK even in an interpreter.

With kind regards,
vovchik

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#761 Post by SFR »

Tasty stuff. :)
Here are Gtkdialog versions, but indeed, they're quite heavy, so on weaker CPUs there may be need to increase 'interval' value.

Thanks & Greetings!
Attachments
spirals.tar.gz
(40.52 KiB) Downloaded 487 times
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#762 Post by vovchik »

Dear SFR,

Very nice. I had to increase the interval from:

Code: Select all

interval="60"
to

Code: Select all

interval="120"
in spiral_4.sh (line 1203) to get my old beater of a computer to respond. It now shows the animated SVG nicely. :)

With kind regards,
vovchik

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

script to explain comboboxtext widget

#763 Post by don570 »

Script to explain comboboxtext widget

I wanted a simpler explanation for the comboboxtext widget
so I wrote this script to show a simple implementation.
Two different methods are shown. The first shows a menu
composed of 'items'. The second has the menu composed from
a list stored in a file on your hard drive.


Image

-------------------------------------------------------------------
Attachments
comboboxtext.sh.gz
remove fake gz extension to obtain script
(1.55 KiB) Downloaded 490 times

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#764 Post by technosaurus »

to eliminate excessive disk writes you can use the ram based file systems on /dev/shm or /tmp for your temporary files ... just don't forget to remove them when you are done.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#765 Post by SFR »

Hey Technosaurus

Yes, I'm using it ever since you told me about it in SelfCrypText thread.
And I prefer /dev/shm, because (AFAIK) /tmp might not be kept in RAM in case of full installs.

_______________

Hmm, windows can grow... Tested under JWM/IceWM.

Code: Select all

#!/bin/bash

# Grow! by SFR'2013
# GPLv2 applies
# Req: Gtkdialog >=0.8.0, Bash

USE_BASH=; [ "`readlink /bin/sh`" != bash ] && USE_BASH="bash -c "

export TEMPDIR=/dev/shm/grow_$$
mkdir $TEMPDIR
trap 'rm -rf $TEMPDIR' EXIT

export PIC=$TEMPDIR/pic.svg
export SIZE=$TEMPDIR/size
echo 16 > $SIZE

grow () {
S=$(<$SIZE); S=$(($S+2)); echo $S > $SIZE
[ $S -ge 512 ] && exit

echo '<svg viewBox="'$((256-($S/2)))' '$((256-($S/2)))' '$S' '$S'" xmlns="http://www.w3.org/2000/svg" version="1.1">
  <circle cx="256" cy="256" r="248" stroke="black" fill="yellow" stroke-width="10" />
  <circle cx="192" cy="160" r="24" stroke="black" fill="black" />
  <circle cx="320" cy="160" r="24" stroke="black" fill="black" />
  <path d="M 128 320 Q 256 416 384 320" stroke="black" fill="none" stroke-width="16" stroke-linecap="round" />
</svg>' > $PIC
}
export -f grow

export MAIN='
<window title="Grow! Grow! GROOOOOW!!!!!      ...ok, that'"'"'s enough...;)">
  <vbox>
    <pixmap>
      <variable>PICTURE</variable>
      <input file>'$PIC'</input>
    </pixmap>
    <timer visible="false" milliseconds="true" interval="75">
      <action>'$USE_BASH'grow</action>
      <action>refresh:PICTURE</action>
    </timer>
  </vbox>
<action signal="hide">exit:abort</action>
</window>
'

gtkdialog -cp MAIN
Have a nice day &
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

hannysabbagh
Posts: 17
Joined: Sun 14 Apr 2013, 10:34

#766 Post by hannysabbagh »

Hello.

anybody knows how to get out of this? :)
http://www.murga-linux.com/puppy/viewtopic.php?t=85640

ThankS!

User avatar
DocSalvage
Posts: 11
Joined: Sat 30 Jun 2012, 18:59
Location: Tallahassee, FL, USA
Contact:

Hyperlinks

#767 Post by DocSalvage »

I'm working on an awk program that converts Zim pages to GtkDialogs for checklists and such so it needs to have functional hyperlinks.

I've learned that the Pango markup "<span><a>..." formats the hypertext just fine but taking action on the click is the problem. I've made it work by wrapping the GtkDialog <text> widget in its own <hbox> which is, in turn, wrapped in an <hbox > for the entire line of text. Conceptually, the code looks something like...

Code: Select all

<hbox>
  <hbox>
    <text>
      <label>"<span>non-link-text</span>"</label>
    </text>
  </hbox>
  <hbox>
    <text>
      <label>"<span><a href="...">link-text</a></span>"</label>
      <action signal="button-press-event">...</action>
    </text>
  </hbox>
  <hbox>
    <text>
      <label>"<span>non-link-text</span>"</label>
    </text>
  </hbox>
</hbox>
Very much a work in progress, but maybe this will help others trying to use hyperlinks.
[i][color=blue]DocSalvager (a.k.a. DocSalvage)[/color][/i]
[url]http://www.docsalvage.info[/url], [url]http://www.softwarerevisions.net[/url]

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

One cuestion.

#768 Post by mister_electronico »

Why don't work this program, and how I can get work.

#! /bin/bash
export CHOOSER
export MAIN_DIALOG='
<vbox>
<chooser>
<height>500</height><width>600</width>
<variable>CHOOSER</variable>
</chooser>
<hbox>
<button help></button>
<button ok></button>
</hbox>
</vbox>
'
gtkdialog --program=MAIN_DIALOG
exec mplayer CHOOSER

I was searching everywhere and I can't see how choose one file and open with some application program, like this example or if I want open file by Menubar.

Thanks for any help.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#769 Post by zigbert »

Code: Select all

exec mplayer "$CHOOSER"

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

No work.

#770 Post by mister_electronico »

Thanks zigbert for answering but don't work.

The problem with the variable CHOOSER inside of GTKDIALOG is local variable, I not know how export variable outside of GTKDIALOG.

The only way I met is :

Code: Select all

#! /bin/bash
export MAIN_DIALOG='
<vbox>
  <chooser>
   <height>500</height><width>600</width>
   <variable>CHOOSER</variable>
  </chooser>
 <hbox>
   <button ok>
      <action>"echo $CHOOSER > /tmp/tmp"</action>
	  <action>exit:Exit</action>
   </button>
 </hbox>
</vbox>
'
gtkdialog --program=MAIN_DIALOG
A=$(cat /tmp/tmp)
echo "$A"
exec mplayer $A

But I think is not very elegant.

Anyway Thanks for you reply.

Post Reply