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 Mon 22 Sep 2014, 10:32
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 41 of 64 [952 Posts]   Goto page: Previous 1, 2, 3, ..., 39, 40, 41, 42, 43, ..., 62, 63, 64 Next
Author Message
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Tue 13 Sep 2011, 00:55    Post subject: gtimer
Subject description: process indicator ( => 0.7.21 )
 

This animated process indicator graphic makes use of the gtkdialog timer feature. Usage:

myfunction() {
gtimer
code .....
kill -9 `ps | grep GTIMER | grep -v grep | awk '{print $1}'`
}
gtimer-2.0.pet
Description 
pet

 Download 
Filename  gtimer-2.0.pet 
Filesize  1.19 KB 
Downloaded  207 Time(s) 
gtimer.png
 Description   
 Filesize   5.56 KB
 Viewed   1172 Time(s)

gtimer.png


Last edited by jpeps on Wed 21 Aug 2013, 02:25; edited 1 time in total
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Wed 21 Sep 2011, 03:42    Post subject:  

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 1 <hbox> OR <vbox>, the widget will remain scalable both horizontally and vertically. Pfind, Pmusic and Pprocess uses various solutions of this.

>> We have of course a trick to scale more complex guis too...
A <hbox> or <vbox> supports the attribute; scrollable, which resets the hbox/vbox definition. You can enclose a widget by 1 <hbox/vbox> inside the scrollable box. The following example explains my words. Remove the scrollable attribute to see how it normally will act.
Code:
#!/bin/sh
export DIALOG='<window default_width="500" default_height="300">
<vbox>
 <text><label>How to scale a complex gui</label></text>
 <hbox scrollable="true">
  <edit></edit>
  <edit></edit>
 </hbox>
</vbox>
</window>'
gtkdialog -p DIALOG

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

Joined: 09 Oct 2006
Posts: 357

PostPosted: Sun 25 Sep 2011, 23:29    Post subject:  

Hi everyone,

I need some help please. I have tried to solve this for two days and I'm baffled. Using a tip from earlier in this thread this dialog was constructed with comments. Only in bash 4.1, I get this warning
“./Pupsave-backup: line 409: warning: here-document at line 305 delimited by end-of-file (wanted `EOV')”

Anyone have an idea how to eliminate that warning? BTW there is no line 409 in the script, 321 lines total.
Code:
 
#snip
#Some escapement is necessary when this sed is used to allow comments in gui.
export PUPSAVE_HOT_BKP=$(cat <<EOV | sed -e 's/#.*//'    # allow comments in gui
<window title="Hot Backup for Frugal Pups" icon-name="gtk-convert" default_width="400">
   <vbox>
      <frame>
         #Pupsave input section
         <text editable="false" use-markup="true" xalign="0.001">
            <label>"<span color='blue'>Pupsave file to backup</span>"</label>
         </text>
         <hbox>
            <entry editable="false">
               <variable>PUPSAVE_PATH</variable>
               <input>validate_fs "\$PUPSAVE_PATH"</input>
            </entry>
            <button>
               <input file stock="gtk-file"></input>
               <action type="fileselect">PUPSAVE_PATH</action>
            </button>
         </hbox>
         #Backup location section
         <text editable="false" use-markup="true" xalign="0.001">
            <label>"<span color='blue'>Save backup to /mnt/??</span>"</label>
         </text>
         <hbox>
            <entry editable="false" accept="directory">
               <variable>BKP_PATH</variable>
               <input>validate_bkp_location "\$BKP_PATH"</input>
            </entry>
            <button>
               <input file stock="gtk-open"></input>
               <action type="fileselect">BKP_PATH</action>
            </button>
         </hbox>
      </frame>
      #Information panel section
      <frame>
         <text editable="false" use-markup="true" xalign="0.001">
            <label>"<span color='blue'>Information</span>"</label>
         </text>
         #Disk MB required
         <text height-request="20" xalign="0.001">
            <variable>TEXT1</variable>
            <input>MBrequired "\$PUPSAVE_PATH"</input>
         </text>
         #Disk MB available
         <text height-request="20" xalign="0.001">
            <variable>TEXT2</variable>
            <input>MBavailable "\$BKP_PATH" "\$PUPSAVE_PATH"</input>
         </text>
         #Backup file name
         <text height-request="40" wrap="false" xalign="0.001">
            <variable>BKPFILE</variable>
            <input>Bkpfilename "\$PUPSAVE_PATH"</input>
         </text>
         <text height-request="40" wrap="false">
            <variable>PROG_PNL</variable>
            <input>P=\`cat "\$TMPFILE4"\`; echo \$P</input>
         </text>
      </frame>
      #Command buttons
      <hbox>
         <button help>
            <action>launch:HOT_BKP_HELP</action>
         </button>
         <button>
            <variable>BTNBKP</variable>
            <input file icon="gtk-save"></input>
            <label>Backup</label>
            <action>disable:BTNQUIT</action>
            <action>Backup "\$PUPSAVE_PATH" "\$BKP_PATH" &</action>
         </button>
         <button use-stock="true" label="gtk-quit" has-focus="true">
            <variable>BTNQUIT</variable>
            <action>EXIT:Exit</action>
         </button>
      </hbox>
      #Event handlers (semi-hidden progress bars)
      <hbox>
         <progressbar height-request="1" width-request="1">
            <input>psbtimer</input>
            <action>refresh:BKP_PATH</action>
            <action>refresh:PUPSAVE_PATH</action>
            <action>refresh:TEXT1</action>
            <action>refresh:TEXT2</action>
            <action>refresh:BKPFILE</action>
            <action>refresh:PROG_PNL</action>
         </progressbar>
         <progressbar height-request="1" width-request="1">      
            <input>PRG=\`pidof Pupsave-backup\`; while [ "\$PRG" > 0 ] ; do sleep 0.2; PRG=\`pidof Pupsave-backup\`; P=\`cat "\$TMPFILE"\`; if [ -x "\$TMPFILE" ];then echo "\$P"; fi; done</input>
            <action>enable:BTNQUIT</action>
            <action>echo 99 > "\$TMPFILE"</action>
         </progressbar>
         <progressbar height-request="1" width-request="1">
            <input>PRH=\`pidof Pupsave-backup\`; while [ "\$PRH" > 0 ] ; do sleep 0.2; PRH=\`pidof Pupsave-backup\`; P=\`cat "\$TMPFILE2"\`; if [ -x "\$TMPFILE2" ];then echo "\$P"; fi; done</input>
            <action>enable:BTNBKP</action>
         </progressbar>
         <progressbar height-request="1" width-request="1">
            <input>PRI=\`pidof Pupsave-backup\`; while [ "\$PRI" > 0 ] ; do sleep 0.2; PRI=\`pidof Pupsave-backup\`; P=\`cat "\$TMPFILE3"\`; if [ -x "\$TMPFILE3" ];then echo "\$P"; fi; done</input>
            <action>disable:BTNBKP</action>
         </progressbar>
      </hbox>
   </vbox>
   <action signal="hide">closewindow:HOT_BKP_HELP</action>
   <action signal="hide">exit:Exit</action>
</window>
EOV)

wgd=`which gtkdialog4`
#snip
 


Regards
2byte

_________________

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


Joined: 18 May 2008
Posts: 4351

PostPosted: Mon 26 Sep 2011, 01:57    Post subject:  

i notice you are using EOV instead of EOF ... is that because an EOF is in one of your variables?

cat normally outputs until EOF (octal \004 ... it can be forced with echo -e "\004")

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
potong

Joined: 06 Mar 2009
Posts: 88

PostPosted: Mon 26 Sep 2011, 09:09    Post subject:  

2byte: "Sometimes it's hard to see the wood for the trees..."

Simplify the code by removing all the flesh and then add it bit by bit back on to the skeleton.
Code:
# export PUPSAVE_HOT_BKP=$(cat <<EOV | sed -e 's/#.*//'    # allow comments in gui
EOV)
# echo "$PUPSAVE_HOT_BKP"

# export PUPSAVE_HOT_BKP=$(cat <<EOV | sed -e 's/#.*//'    # allow comments in gui
<window title="Hot Backup for Frugal Pups" icon-name="gtk-convert" default_width="400">
EOV)
# echo "$PUPSAVE_HOT_BKP"
<window title="Hot Backup for Frugal Pups" icon-name="gtk-convert" default_width="400">
# export PUPSAVE_HOT_BKP=$(cat <<EOV | sed -e 's/#.*//'    # allow comments in gui
<window title="Hot Backup for Frugal Pups" icon-name="gtk-convert" default_width="400">
   <vbox>
EOV)
# echo "$PUPSAVE_HOT_BKP"
<window title="Hot Backup for Frugal Pups" icon-name="gtk-convert" default_width="400">
   <vbox>
#...
Of course there may be a problem in bash4.1?
Does this ring any bells?

If not maybe this may throw some light on the problem.

HTH

Potong
Back to top
View user's profile Send private message 
2byte

Joined: 09 Oct 2006
Posts: 357

PostPosted: Mon 26 Sep 2011, 11:45    Post subject:  

Thanks guys

potong, your links led to the solution.
Quote:
A here-document is supposed to be
terminated by a line containing the delimiter followed by a newline


The solution?
Code:

</window>
EOV
)


Sometimes the simplest things ...

_________________

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


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

PostPosted: Sat 01 Oct 2011, 04:13    Post subject:  

Thunor has enlightened us with a huge speed improvement for complex guis. I have updated first post - Speed issues
______________________________________________________________________

>> For an unknown reason, it is much faster to start your gtkdialog-xml-code from a file than from a variable.
gtkdialog --file=filename
gtkdialog --program=variable
The file alternative is highly recommended if your xml-code is getting complex.

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


Joined: 03 Apr 2007
Posts: 3368
Location: Oregon

PostPosted: Sat 01 Oct 2011, 05:02    Post subject:  

I hope I have it right, but I have written a gtkdialog script that uses a progress bar in its actions. It was written to restore 2byte's backed up pupsave files, but you can use it to copy a file to another destination.
I ran into a problem after uploading it and found that I had not allowed sufficient time for the copy to start and so a check of the destination file size failed and caused errors in the execution of the script.
Anyway, if you want to try it and see how I got a progress bar to work, just get the file from "Additional Software - utilities". It is under the heading of "Restore Pupsave file....".

I did this as a challenge as I had not seen any actual applications that used a progress bar.
The examples to me do not count because they only increment numbers to make the bar advance with no provision as to how one would use it in an application.
If it bombs for you, open the script in a text editor such as geany and increase the sleep value on line 25.
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Sat 01 Oct 2011, 11:33    Post subject:  

8-bit wrote:


I did this as a challenge as I had not seen any actual applications that used a progress bar.

petcheck has one, also swapfilemanager (although not a bar...just an animated graphic).
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Sat 01 Oct 2011, 17:13    Post subject:  

zigbert wrote:
Thunor has enlightened us with a huge speed improvement for complex guis. I have updated first post - Speed issues
______________________________________________________________________

>> For an unknown reason, it is much faster to start your gtkdialog-xml-code from a file than from a variable.
gtkdialog --file=filename
gtkdialog --program=variable
The file alternative is highly recommended if your xml-code is getting complex.


Anyone have a theory on how this could happen? Something using file i/o being faster than memory?

Wait... perhaps it's because Gtkdialog reloads the entire program whenever called, whereas - if from a file it's displayed immediately?

Cheers,
s
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3368
Location: Oregon

PostPosted: Sat 01 Oct 2011, 22:02    Post subject:  

UPDATE!
The Restore Pupsave utility I uploaded may not handle just copying a file since it was written to remove the date-time from a backed up pupsave file.
It uses sed to remove the last 19 characters in the filename after the source path is removed.
I wanted to pass that along to all that try to use it to copy files.
Back to top
View user's profile Send private message 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Sun 02 Oct 2011, 07:59    Post subject:  

seaside wrote:
Anyone have a theory on how this could happen? Something using file i/o being faster than memory?

Wait... perhaps it's because Gtkdialog reloads the entire program whenever called, whereas - if from a file it's displayed immediately?

Cheers,
s

I've found the issue and it's fixed in r308.

The problem was that strlen() was being called for every char read from memory to check that a char wasn't being read past the end, but this was pointless anyway since an environment variable is null terminated which is being checked for too.

Reading from a file or stdin are both fine though and it'd be a good idea to stick to these methods for complex apps until everyone is using at least r308.

Something else I've found: loading my rather large app from an environment variable is causing bash to display an error message: "./myapp: line 192: /usr/sbin/gtkdialog: Argument list too long", so I have to load from a file or stdin anyway. The limit I am experiencing which bash won't accept above is somewhere around 123KB.

Regards,
Thunor
Back to top
View user's profile Send private message Visit poster's website 
Geoffrey


Joined: 30 May 2010
Posts: 1381
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Tue 11 Oct 2011, 10:18    Post subject:  

post deleted and moved
Back to top
View user's profile Send private message 
SK7000

Joined: 12 Oct 2011
Posts: 4

PostPosted: Wed 12 Oct 2011, 15:03    Post subject: comboboxtext searching?  

Hello,

Today I discovered gtkdialog while building a minimal GUI around a commandline application I use frequently. I've got pretty much everything working except two things.

The first is behaviour I've come to expect of all comboboxes I've come across, and it is to be able to search the entry you are looking for by typing the first few characters. It appears that "comboboxtext" areas in Gtkdialog don't have this functionality built-in, not even the advanced demos do it.

So, is there any way to do it, either by setting some property or clever action-binding?

The second is quite simple, I just can't figure out a way so that the dialogue's "OK" button gets pressed when the user presses Enter while the comboboxtext area is focused. I didn't see any actions that can be bound to the Enter key.

So, again, is there some way to do this?

I imagine I could do without, but it's a bit slow searching the entry you want (amongst a few dozens) without help from the keyboard :/

PS: Thanks for a very interesting and flexible application Surprised
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Wed 12 Oct 2011, 15:08    Post subject:  

I was looking for some simple on screen 600 pixel ruler but nothing I found was simple so
here is as simple as it gets

there is vertical ruler included also
gtk-movable-ruler.png
 Description   
 Filesize   13.77 KB
 Viewed   1024 Time(s)

gtk-movable-ruler.png

ruler.tar.gz
Description 
gz

 Download 
Filename  ruler.tar.gz 
Filesize  8.67 KB 
Downloaded  231 Time(s) 

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 41 of 64 [952 Posts]   Goto page: Previous 1, 2, 3, ..., 39, 40, 41, 42, 43, ..., 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.1647s ][ Queries: 12 (0.0359s) ][ GZIP on ]