Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 28 Aug 2014, 07:26
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 4 of 64 [947 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, ..., 62, 63, 64 Next
Author Message
nikin

Joined: 14 Sep 2009
Posts: 18

PostPosted: Tue 22 Sep 2009, 16:35    Post subject: 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 Razz

PS:
dear vovchik: the icon is nice but aa bit blurry? or thats intended to be?
ppdf016screenshot.png
 Description   and a screenshot
 Filesize   6.72 KB
 Viewed   1878 Time(s)

ppdf016screenshot.png

ppdf-0.1.6.tar.gz
Description  ppdf and ppdf helper
gz

 Download 
Filename  ppdf-0.1.6.tar.gz 
Filesize  2.22 KB 
Downloaded  532 Time(s) 
ppdf-0.1.6.pet
Description  ppdf 0.1.6 pet
pet

 Download 
Filename  ppdf-0.1.6.pet 
Filesize  2.91 KB 
Downloaded  539 Time(s) 
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Tue 22 Sep 2009, 17:49    Post subject:  

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 Smile

With kind regards,
vovchik
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Wed 23 Sep 2009, 03:47    Post subject:  

Dear nikin,

Another icon attempt. This one is much less fuzzy....

With kind regards,
vovchik
ppdf-logo-but.png
 Description   
 Filesize   25.95 KB
 Viewed   1807 Time(s)

ppdf-logo-but.png

Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Wed 23 Sep 2009, 04:25    Post subject:  

Dear nikin,

And here is a modified version of my first attempt at an icon, with fuzziness removed.

With kind regards,
vovchik
ppdf-logo-but2.png
 Description   
 Filesize   25.45 KB
 Viewed   1807 Time(s)

ppdf-logo-but2.png

Back to top
View user's profile Send private message 
nikin

Joined: 14 Sep 2009
Posts: 18

PostPosted: Wed 23 Sep 2009, 17:49    Post subject:  

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
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5684
Location: Valåmoen, Norway

PostPosted: Thu 24 Sep 2009, 14:11    Post subject:  

Drag'n drop
Gtkdialog supports drag'n drop from filebrowser (rox) to <entry> widget.
Code:
export test="
<entry accept=\"directory\" width-request=\"300\">
 <default>Drag a directory from Rox</default>
</entry>"
gtkdialog3 -p test


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.
Code:
#!/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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Fri 25 Sep 2009, 16:59    Post subject:  

zigbert,

Thanks for posting this. It's absolutely amazing what can be done with Gtkdialog.

It's really sad that the documentation is silent on all the possibilities available.

Keep the hints and tricks coming Very Happy
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5684
Location: Valåmoen, Norway

PostPosted: Mon 28 Sep 2009, 16:27    Post subject:  

Okay, here is todays gtkdialog trick. Smile

How to add support of tail/log-text. Change TITLE and TAILFILE to see other info than /var/log/messages.

Code:
#!/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



_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5684
Location: Valåmoen, Norway

PostPosted: Tue 29 Sep 2009, 12:32    Post subject:  

Todays lesson is the explanation of yesterdays tailbox trick. It can be used for endless of funny code. You'll find it in the main post - chapter 4.


Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5684
Location: Valåmoen, Norway

PostPosted: Wed 30 Sep 2009, 04:58    Post subject:  

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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Sat 03 Oct 2009, 20:34    Post subject:  

Zigbert,

Great material. This tutorial will soon be ready for prime time television. Very Happy

There is no where else to find all of these valuable guidelines and most of all - thank you for taking the time to explain.

Best regards,
s
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7794
Location: qld

PostPosted: Sat 03 Oct 2009, 21:03    Post subject:  

Remebering our Radio Button Choice

Hello guys and gals Smile

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:

<radiobutton>
 <variable>VAR</variable>
  <label>some text</label>
   <default>true</default>
</radiobutton>



The key there is the <default> tag. It must be true or equate to true.

Question How do we get it to equate to "true" then?

Idea 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:
VAR1=true
VAR2=false


That will make VAR1 the default.

So, our gtkdialog script now looks like this-
Code:
<radiobutton>
 <variable>VAR1</variable>
  <label>some text</label>
   <default>$VAR1</default>
<radiobutton>
 <variable>VAR2</variable>
  <label>some other text</label>
   <default>$VAR2</default>
</radiobutton>


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 Smile )

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:
#!/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


Make this text file in your directory named "variables"
Code:

VAR1=true
VAR2=false


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 Smile I have made a working example here- for Eeepcs http://www.murga-linux.com/puppy/viewtopic.php?p=347561#347561

Cheers Very Happy

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5684
Location: Valåmoen, Norway

PostPosted: Sun 04 Oct 2009, 04:27    Post subject:  

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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5684
Location: Valåmoen, Norway

PostPosted: Sun 04 Oct 2009, 05:28    Post subject:  

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:
Code:
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:
#!/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


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.

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5684
Location: Valåmoen, Norway

PostPosted: Sun 04 Oct 2009, 10:51    Post subject:  

###################################################################################
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.

. . . . . . .

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 4 of 64 [947 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, ..., 62, 63, 64 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1125s ][ Queries: 12 (0.0099s) ][ GZIP on ]