GtkDialog - tips
PPDF 0.1.6
hy everyone.
ppdf 0.1.6 is here.
- unnescesary line removed (thanks seaside)
- there is now dependency check on the apps used. with gxdialog error message
- helper script included
and now i have managed to build a pet package of it with menu entry and all
i hope everything works fine.
please test it
PS:
dear vovchik: the icon is nice but aa bit blurry? or thats intended to be?
ppdf 0.1.6 is here.
- unnescesary line removed (thanks seaside)
- there is now dependency check on the apps used. with gxdialog error message
- helper script included
and now i have managed to build a pet package of it with menu entry and all
i hope everything works fine.
please test it
PS:
dear vovchik: the icon is nice but aa bit blurry? or thats intended to be?
- Attachments
-
- ppdf016screenshot.png
- and a screenshot
- (6.72 KiB) Downloaded 2474 times
-
- ppdf-0.1.6.tar.gz
- ppdf and ppdf helper
- (2.22 KiB) Downloaded 870 times
-
- ppdf-0.1.6.pet
- ppdf 0.1.6 pet
- (2.91 KiB) Downloaded 874 times
Dear nikin,
I will work on the icon - it is a bit blurry. With v.1.6 I have Abiword launching three instances after I quit. Can't be right. I will look tomorrow at the source. The dep check is a good idea. I think an ext check would also be in order (see above), because people might wish to print binary executables, for example
With kind regards,
vovchik
I will work on the icon - it is a bit blurry. With v.1.6 I have Abiword launching three instances after I quit. Can't be right. I will look tomorrow at the source. The dep check is a good idea. I think an ext check would also be in order (see above), because people might wish to print binary executables, for example
With kind regards,
vovchik
Dear nikin,
Another icon attempt. This one is much less fuzzy....
With kind regards,
vovchik
Another icon attempt. This one is much less fuzzy....
With kind regards,
vovchik
- Attachments
-
- ppdf-logo-but.png
- (25.95 KiB) Downloaded 2322 times
Dear nikin,
And here is a modified version of my first attempt at an icon, with fuzziness removed.
With kind regards,
vovchik
And here is a modified version of my first attempt at an icon, with fuzziness removed.
With kind regards,
vovchik
- Attachments
-
- ppdf-logo-but2.png
- (25.45 KiB) Downloaded 2326 times
i like the ppdf-logo-but.png one.
as you my have seen imade a small icon..
Did youtake alokk in the abiword problem... i couldn't reproduce it.
I started a new topic for the program
http://www.murga-linux.com/puppy/viewtopic.php?t=46932
as you my have seen imade a small icon..
Did youtake alokk in the abiword problem... i couldn't reproduce it.
I started a new topic for the program
http://www.murga-linux.com/puppy/viewtopic.php?t=46932
Drag'n drop
Gtkdialog supports drag'n drop from filebrowser (rox) to <entry> widget.
But this is not all....The next script shows how to move items in list by drag'n drop. This example shows only one list, but it is of course possible to drag between 2 lists. Pmusic 0.9.0 shows this in practice.
Gtkdialog supports drag'n drop from filebrowser (rox) to <entry> widget.
Code: Select all
export test="
<entry accept=\"directory\" width-request=\"300\">
<default>Drag a directory from Rox</default>
</entry>"
gtkdialog3 -p test
Code: Select all
#!/bin/sh
move (){
PRESS_EVENT="`cat /tmp/PRESS_EVENT`"
grep -Fv "$PRESS_EVENT" /tmp/list > /tmp/tmp
grep -Fm1 -B500 "$TREE" /tmp/tmp | grep -v "$TREE" > /tmp/tmp1
echo "$PRESS_EVENT" >> /tmp/tmp1
grep -Fm1 -A500 "$TREE" /tmp/tmp >> /tmp/tmp1
mv -f /tmp/tmp1 /tmp/list
}
export -f move
ls -1 /usr/share/backgrounds > /tmp/list
export test="
<tree rules_hint=\"true\" hover-selection=\"true\" tooltip-text=\"Drag'n drop items to move them in list\">
<label>Backgrounds</label>
<input>cat /tmp/list</input>
<variable>TREE</variable>
<height>300</height><width>200</width>
<action signal=\"button-press-event\">echo \$TREE > /tmp/PRESS_EVENT</action>
<action signal=\"button-release-event\">move</action>
<action signal=\"button-release-event\">refresh:TREE</action>
</tree>"
gtkdialog3 -p test
Okay, here is todays gtkdialog trick.
How to add support of tail/log-text. Change TITLE and TAILFILE to see other info than /var/log/messages.
How to add support of tail/log-text. Change TITLE and TAILFILE to see other info than /var/log/messages.
Code: Select all
#!/bin/sh
export TITLE="Kernel messages"
export TAILFILE=/var/log/messages
echo 99 > /tmp/tailbox_progress
echo " " > /tmp/tailbox_text
tailing (){
I=`cat /tmp/tailbox_progress`
echo $TITLE
echo $I
sleep 1
[ -s "$TAILFILE" ] && tail -n 20 "$TAILFILE" | tr '\r' '\n' | tail -n 20 > /tmp/tailbox_text
echo 100 > /tmp/tailbox_progress
}
export -f tailing
export tailbox="
<window title=\"tailbox\">
<vbox>
<progressbar>
<input>"'while [ A != B ]; do tailing; done'"</input>
<action>refresh:TAIL</action>
<action>echo 99 > /tmp/tailbox_progress</action>
</progressbar>
<edit>
<variable>TAIL</variable>
<input file>/tmp/tailbox_text</input>
<width>300</width><height>380</height>
</edit>
</vbox>
</window>"
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog3 -p tailbox); do
eval $STATEMENTS
done
IFS=$I
MIME
What should happen when user double-click on an image-file in your gui. In some cases it is logical to show the image in an image-viewer. But....it is no need of linking all kinds of extensions to different programs. - It is already done by the filebrowser. Puppy uses 'rox' and if you execute 'rox /path/image.png' the image will show up in the defined viewer. Just as simple as that.
See main post for complete gtkdialog-guide
What should happen when user double-click on an image-file in your gui. In some cases it is logical to show the image in an image-viewer. But....it is no need of linking all kinds of extensions to different programs. - It is already done by the filebrowser. Puppy uses 'rox' and if you execute 'rox /path/image.png' the image will show up in the defined viewer. Just as simple as that.
See main post for complete gtkdialog-guide
Remebering our Radio Button Choice
Hello guys and gals
I just thought I would share this as it is not well documented. There are 2 examples in Puppy that I know of, Pfind and Nathan Wallpaper Setter.
Imagine you have an app that you use and it has radio buttons. Now, of the choice you make of those radio buttons you would like to remember that choice next time you start the app. It is quite simple-
The key there is the <default> tag. It must be true or equate to true.
How do we get it to equate to "true" then?
We need some sort of config file where the values of the variables are stored and changed accordingly.
Ok then we create this file. For this case it is called simply "variables". (There are a number of ways this file can be derived but that is not the point here.)
Lets say we have VAR1 and VAR2. In our "variables" file then we need
That will make VAR1 the default.
So, our gtkdialog script now looks like this-
Ah.. but how do we change the value from true to false?
In this case, to keep it simple, we redirect the standard output to our variables file
----------------
Now we try it! (the fun part )
Make a directory on your system, I'll call mine "radiobutton-test" and I'm creating it in /root. Make it where ever you want but remember the path.
Make this text file in your directory named "variables"
Make your script executable and run it! Your radio button choice will be remembered!
TIP: In this example, do not kill the window because then there is no standard output. This is why you can not use standard output in this manner. There are plenty of other ways I have made a working example here- for Eeepcs http://www.murga-linux.com/puppy/viewto ... 561#347561
Cheers
Hello guys and gals
I just thought I would share this as it is not well documented. There are 2 examples in Puppy that I know of, Pfind and Nathan Wallpaper Setter.
Imagine you have an app that you use and it has radio buttons. Now, of the choice you make of those radio buttons you would like to remember that choice next time you start the app. It is quite simple-
Code: Select all
<radiobutton>
<variable>VAR</variable>
<label>some text</label>
<default>true</default>
</radiobutton>
How do we get it to equate to "true" then?
We need some sort of config file where the values of the variables are stored and changed accordingly.
Ok then we create this file. For this case it is called simply "variables". (There are a number of ways this file can be derived but that is not the point here.)
Lets say we have VAR1 and VAR2. In our "variables" file then we need
Code: Select all
VAR1=true
VAR2=false
So, our gtkdialog script now looks like this-
Code: Select all
<radiobutton>
<variable>VAR1</variable>
<label>some text</label>
<default>$VAR1</default>
<radiobutton>
<variable>VAR2</variable>
<label>some other text</label>
<default>$VAR2</default>
</radiobutton>
In this case, to keep it simple, we redirect the standard output to our variables file
----------------
Now we try it! (the fun part )
Make a directory on your system, I'll call mine "radiobutton-test" and I'm creating it in /root. Make it where ever you want but remember the path.
Code: Select all
#!/bin/bash
WORKDIR="/root/radiobutton-test"
. $WORKDIR/variables
export radiobuttonfun="
<window title=\"fun?\">
<vbox>
<frame Having fun yet?>
<radiobutton>
<variable>VAR1</variable>
<label>Yes I am</label>
<default>$VAR1</default>
</radiobutton>
<radiobutton>
<variable>VAR2</variable>
<label>No I'm not</label>
<default>$VAR2</default>
</radiobutton>
</frame>
<hbox>
<button ok></button>
</hbox>
</vbox>
</window>"
gtkdialog3 --program=radiobuttonfun > $WORKDIR/variables
Code: Select all
VAR1=true
VAR2=false
TIP: In this example, do not kill the window because then there is no standard output. This is why you can not use standard output in this manner. There are plenty of other ways I have made a working example here- for Eeepcs http://www.murga-linux.com/puppy/viewto ... 561#347561
Cheers
Puppy Linux Blog - contact me for access
5.) The benefits of a config file - Set default status of Radiobuttons, Comboboxes...
A config file is a nice way to store the settings in your program. At next startup, it will show setting like you left them last time. An easy way to use a config file is to run it like an ordinary bash-script, and include variable definition in it. It is most common to keep config files in home directory as a hidden file ($HOME/.testrc). The file might look like this:
Now let's go to the main script. For the radiobuttons and the entry, we set the <default> tag to the coresponding variable in the config file. Since the combobox doesn't support the <default> tag, we need a workaround. We simply builds the combobox item-list so show our saved variable first.
The last codeline redirects output (variable values) to our config file instead of to the terminal.
Note that line 2 starts with a dot. It makes a huge different if you skip it.
. $HOME/.config --> run script as a childprocess as the main process. The variable values in the config file are reachable for the main script.
$HOME/.config --> run script as a new process as the main process. The variable values in the config file will NOT be reachable for the main script.
A config file is a nice way to store the settings in your program. At next startup, it will show setting like you left them last time. An easy way to use a config file is to run it like an ordinary bash-script, and include variable definition in it. It is most common to keep config files in home directory as a hidden file ($HOME/.testrc). The file might look like this:
Code: Select all
COMBOBOX="item 3"
ENTRY="default text"
RADIOBUTTON1="false"
RADIOBUTTON2="true"
Now let's go to the main script. For the radiobuttons and the entry, we set the <default> tag to the coresponding variable in the config file. Since the combobox doesn't support the <default> tag, we need a workaround. We simply builds the combobox item-list so show our saved variable first.
Code: Select all
#!/bin/bash
. $HOME/.testrc
#in case no testc file (first run), build the file
[ ! -s $HOME/.testrc ] && echo -n 'COMBOBOX="item 3"\nENTRY="default text"\nRADIOBUTTON1="false"\nRADIOBUTTON2="true"'
#define combobox list items
COMBOBOX_ITEMS="<item>$COMBOBOX</item>" #stored value should be first in list
for I in 1 2 3 4; do COMBOBOX_ITEMS=`echo "$COMBOBOX_ITEMS<item>item $I</item>"`; done
export test="
<window title=\"The benefits of a config file\">
<vbox>
<frame The first item of list is the default choice in a Combobox>
<combobox>
<variable>COMBOBOX</variable>
$COMBOBOX_ITEMS
</combobox>
</frame>
<frame If nothing else is set, the first radiobutton is the active one>
<radiobutton>
<variable>RADIOBUTTON1</variable>
<label>Yes I am</label>
<default>$RADIOBUTTON1</default>
</radiobutton>
<radiobutton>
<variable>RADIOBUTTON2</variable>
<label>No I'm not</label>
<default>$RADIOBUTTON2</default>
</radiobutton>
</frame>
<frame Fetch entry-value from config file>
<entry>
<variable>ENTRY</variable>
<default>$ENTRY</default>
</entry>
</frame>
<hbox>
<button ok></button>
</hbox>
</vbox>
</window>"
gtkdialog3 -p test > $HOME/.testrc
Note that line 2 starts with a dot. It makes a huge different if you skip it.
. $HOME/.config --> run script as a childprocess as the main process. The variable values in the config file are reachable for the main script.
$HOME/.config --> run script as a new process as the main process. The variable values in the config file will NOT be reachable for the main script.
###################################################################################
6.) Speed issues - Let your turtle run
###################################################################################
Gtkdialog is not a fast gui-lib. If you are building a gui where speed matters, please check the following notes.
>> If you include a long list in your gui, you should consider to use the <table> widget instead of <tree> or <list>. While <tree> and <list> first reads content of list, and then render it, the <table> renders while content is read.
>> Progressbars can suck your cpu-power. Adding a reasonable sleep value in the loop helps a lot.
>> Run large calculations as a background process. Pmusic builtin filebrowser (version 0.9) first shows songs in the directory, then it starts a background process to find meta informations of the songs. When finished, it renders the song-list once again, now with complete information. How to use a background process with gtkdialog is explained in the chapter 'Let external code act on your gtkdialog gui'.
>> Even if gtkdialog is slow, your bash-code might make it MUCH slower. Be careful with the use of subshells, and slow commands as sed, ps, expr... This is of course most important when building a loop.
>> There are many ways of building a gui. The pictures below shows the builtin filebrowser/filesearch in Pburn 2 (left) and Pburn 3. The code has shrunk from 3110 to 997 chars. It does exactly the same, and the speed improvement are notable.
. . . . . . .
6.) Speed issues - Let your turtle run
###################################################################################
Gtkdialog is not a fast gui-lib. If you are building a gui where speed matters, please check the following notes.
>> If you include a long list in your gui, you should consider to use the <table> widget instead of <tree> or <list>. While <tree> and <list> first reads content of list, and then render it, the <table> renders while content is read.
>> Progressbars can suck your cpu-power. Adding a reasonable sleep value in the loop helps a lot.
>> Run large calculations as a background process. Pmusic builtin filebrowser (version 0.9) first shows songs in the directory, then it starts a background process to find meta informations of the songs. When finished, it renders the song-list once again, now with complete information. How to use a background process with gtkdialog is explained in the chapter 'Let external code act on your gtkdialog gui'.
>> Even if gtkdialog is slow, your bash-code might make it MUCH slower. Be careful with the use of subshells, and slow commands as sed, ps, expr... This is of course most important when building a loop.
>> There are many ways of building a gui. The pictures below shows the builtin filebrowser/filesearch in Pburn 2 (left) and Pburn 3. The code has shrunk from 3110 to 997 chars. It does exactly the same, and the speed improvement are notable.
. . . . . . .
Hi Sigmund,zigbert wrote:Hello Mick
Nice tutorial!
I will include this in the main post, but thought it might fit better as a new chapter - The benefits of a config file.
- Both <entry> and <edit> widgets uses the <default> tag.
- How to activate a given item in a combobox.
Sigmund
Glad I could add something useful to this thread. It has some nice info.
Mick
Puppy Linux Blog - contact me for access
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I was trying to get some more documentation on GTK Dialog and figured out a reason why there may not be much documentation thus far. It seems that it was an intermediated step / building block for these:
CUI http://linux.pte.hu/~pipas/CUI/index.html
GUI Completion http://linux.pte.hu/~pipas/GUIcompletion/index.html
So goes the development cycle on a project with a small or one man team. They do look pretty promising for a couple of my projects (Pcompile in particular) Has anyone here done anything with them yet?
CUI http://linux.pte.hu/~pipas/CUI/index.html
GUI Completion http://linux.pte.hu/~pipas/GUIcompletion/index.html
So goes the development cycle on a project with a small or one man team. They do look pretty promising for a couple of my projects (Pcompile in particular) Has anyone here done anything with them yet?
Last edited by technosaurus on Mon 05 Oct 2009, 22:15, edited 1 time in total.
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].
I looked at them the other day, but I can't remember why I gave up on them. I think one had some unreasonable (gnome?) dependencies.
Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
Make the gui scalable
>> Did you know that it is possible to make gtkdialog windows fully scalable? That means to be able to drag the window corner, and make the gui bigger.
As long as a <tree>, <table>, <list> or <edit> widget is enclosed ONLY by a <hbox> OR <vbox>, the widget will remain scalable both horizontally and vertically. Pfind, Pmusic and Pprocess uses various solutions of this.
>> Note about frames
If you enclose a <frame> with <hbox> or <vbox>, you set a fixed size of the frame. If you instead put the <hbox>/<vbox> definitions inside the <frame>, the frame will dynamically scale to fit gui.
>> Did you know that it is possible to make gtkdialog windows fully scalable? That means to be able to drag the window corner, and make the gui bigger.
As long as a <tree>, <table>, <list> or <edit> widget is enclosed ONLY by a <hbox> OR <vbox>, the widget will remain scalable both horizontally and vertically. Pfind, Pmusic and Pprocess uses various solutions of this.
>> Note about frames
If you enclose a <frame> with <hbox> or <vbox>, you set a fixed size of the frame. If you instead put the <hbox>/<vbox> definitions inside the <frame>, the frame will dynamically scale to fit gui.
Hi zigbert; I need help with the "tree", I don`t see how the sub levels are controlled.
This should give multi. levels but only gives a few, but what designates the sub levels?
The code above is gtk-2, so gtk-3 may be a better choice...
I`m trying to make a "WinExplorer" type file browser, left pane = dir. tree, right pane = file list.
Code: Select all
#! /bin/bash
export MAIN_DIALOG='
<vbox>
<tree>
<input file>tmp.text</input>
<label>Device</label>
<item stock="gtk-harddisk">Hard Disk</item>
<item stock="gtk-floppy">Floppy Disk</item>
<item stock="gtk-floppy">Floppy Disk</item>
<item stock="gtk-floppy">Floppy Disk</item>
<item stock="gtk-cdrom">CD_ROM Drive</item>
<height>200</height>
<width>300</width>
<variable>TREE</variable>
</tree>
</vbox>
'
gtkdialog2 --program=MAIN_DIALOG
The code above is gtk-2, so gtk-3 may be a better choice...
I`m trying to make a "WinExplorer" type file browser, left pane = dir. tree, right pane = file list.