GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
livernote1
Posts: 3
Joined: Sat 09 Sep 2017, 03:36

#1221 Post by livernote1 »

misko_2083 wrote:
livernote1 wrote:Guys help needed, been working with this progress bar if using the example like give in page page 1 it is working fine but after i change the action it seem the program is running on the background only the progress bar is just silence

Code: Select all

<frame Progress>
    <text>
      <label>Duplication process is happening.</label>
    </text>
    <progressbar>
      <input>dd if=/dev/sda of=/dev/sdb</input>
	  <action>launch:END_DIALOG</action>
    </progressbar>
  </frame>
This is a way to show the progress bar with dd and pv in terminal.

Code: Select all

USB="/dev/sdb"
ISO_IMAGE="/path/to/ubuntu-15.04-desktop-amd64.iso"
SIZE=$(du -h -B1 "$ISO_IMAGE" | awk '{print $1}')

dd if="$ISO_IMAGE" | pv -s "$SIZE" | dd of="$USB" bs=4M oflag=dsync
With oflag=dsync dd will ask for completely synchronous output to disk. Slower but you'll have a progress bar.

Someone asked how to do this with yad.
To show this in a UI you need line by line output. For that add -n to pv.

Code: Select all

USB="/dev/sdb"
 ISO_IMAGE="/path/to/ubuntu-15.04-desktop-amd64.iso"
 SIZE=$(du -h -B1 "$ISO_IMAGE" | awk '{print $1}')

(dd if="$ISO_IMAGE" | pv -n -s "$SIZE" | dd of="$USB" bs=4M oflag=dsync) 2>&1 | \
  yad --center --borders=6 --title="Image writer" --text="$(echo -e "Writing $(basename "$ISO_IMAGE"):")"\
        --width=300 --progress --no-buttons --auto-close --image=system-run --window-icon=drive-removable-media-usb
You can apply something similar with gtkdialog.
i have try me best to understand but apparently still cant make the progress bar in the gtkdialog moving...its work smoothly if i just want to use the pv at terminal but on the gtkdialog interface the progress bar is no moving :(

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

#1222 Post by don570 »

Tip for a horizontal line of buttons at the bottom of a window (see image)

Instead of all the icons sharing the window equally
or force them all to the right side , I found a way to
give a button less space. In the example the help button
is small and on the left side. The other two buttons share the remaining space equally.

Code: Select all

#!/bin/sh


export TEXTSTRING="$(gettext 'How to use pho
Usage: : pho *.jpg (or whatever format). ')"

export VIEWER='
<window title="Experiment">
     <vbox   width-request="740">
             <text><label>Experiment</label></text>


             <hseparator></hseparator>
  
            <hbox>    
                       <button   space-expand="false" space-fill="false"> 
                      <input file stock="gtk-help"></input>
                       <action>Xdialog --title "'$(gettext 'Help')'"  --ok-label "'$(gettext 'OK')'" --backtitle "\n$TEXTSTRING \n "  --msgbox  "" 0 0 &</action>
                       </button> 


            <hbox   space-expand="true" space-fill="true">
                       <button>
                      <input file stock="gtk-cancel"></input>
                      <label>Cancel</label>
                     </button>

                      <button>
                       <input file stock="gtk-apply"></input>
                       <label>Proceed</label>        
                      <action>xmessage clicked</action>  
                      <action type="exit">CLOSE</action>           
                      </button> 
    
            </hbox></hbox>

      </vbox>
</window>'

gtkdialog -p VIEWER --center



Attachments
screenshot-script.png
(8.65 KiB) Downloaded 480 times

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

#1223 Post by don570 »

Here is final app --> pho viewer

http://murga-linux.com/puppy/viewtopic. ... 027#974027
____________________________________________________
Attachments
screenshot-pho.png
(31.41 KiB) Downloaded 430 times

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#1224 Post by mavrothal »

I was wondering if anyone has any idea under what conditions the gtkdialog elements of an app/script may be shown in reverse order
i.e. from bottom to top and from right to left (see pick below)

Should point out that this is with the mac version of gtkdialog :oops: , but still...
The gtkdialog dependencies appear to be ok, btw

Code: Select all

gm$ otool -L /usr/local/bin/gtkdialog # otool is the dll equivalent for ox x
/usr/local/bin/gtkdialog:
/usr/local/opt/gtk+/lib/libgtk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/gtk+/lib/libgdk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/pango/lib/libpangocairo-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/pango/lib/libpango-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/atk/lib/libatk-1.0.0.dylib (compatibility version 22210.0.0, current version 22210.1.0)
/usr/local/opt/cairo/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.6.0)
/usr/local/opt/gdk-pixbuf/lib/libgdk_pixbuf-2.0.0.dylib (compatibility version 3601.0.0, current version 3601.0.0)
/usr/local/opt/glib/lib/libgio-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libgobject-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libglib-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.5.0)
/usr/local/opt/glib/lib/libgthread-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Attachments
gtkdialog_mac.png
(171.68 KiB) Downloaded 410 times
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#1225 Post by 01micko »

mavrothal wrote:I was wondering if anyone has any idea under what conditions the gtkdialog elements of an app/script may be shown in reverse order
i.e. from bottom to top and from right to left (see pick below)

Should point out that this is with the mac version of gtkdialog :oops: , but still...
The gtkdialog dependencies appear to be ok, btw

Code: Select all

gm$ otool -L /usr/local/bin/gtkdialog # otool is the dll equivalent for ox x
/usr/local/bin/gtkdialog:
/usr/local/opt/gtk+/lib/libgtk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/gtk+/lib/libgdk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/pango/lib/libpangocairo-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/pango/lib/libpango-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/atk/lib/libatk-1.0.0.dylib (compatibility version 22210.0.0, current version 22210.1.0)
/usr/local/opt/cairo/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.6.0)
/usr/local/opt/gdk-pixbuf/lib/libgdk_pixbuf-2.0.0.dylib (compatibility version 3601.0.0, current version 3601.0.0)
/usr/local/opt/glib/lib/libgio-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libgobject-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libglib-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.5.0)
/usr/local/opt/glib/lib/libgthread-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Said 'mac version' seems to exhibit the exact same problem of arm versions before jamesbond patched it... (take a close look at the screeny from your linked thread :wink: ).

You can try applying the untested patch attached.

NB: possibly in automaton.c (refer to patch) there are other possibilities. '__APPLE__' may work. If not replace it with '__MACH__'.
Attachments
apple_gtkdialog.patch.gz
real gzip (lol)
(343 Bytes) Downloaded 160 times
Puppy Linux Blog - contact me for access

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#1226 Post by mavrothal »

01micko wrote: Said 'mac version' seems to exhibit the exact same problem of arm versions before jamesbond patched it... (take a close look at the screeny from your linked thread :wink: ).

You can try applying the untested patch attached.

NB: possibly in automaton.c (refer to patch) there are other possibilities. '__APPLE__' may work. If not replace it with '__MACH__'.
This was it!
Needed some more changes to build but it worked.
Find the final gtkdialog mac binary and patch in the original post
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

slippery60
Posts: 5
Joined: Mon 18 Dec 2017, 20:31
Location: Fairmont, WV

How to calculate an suggested value for an entry widget

#1227 Post by slippery60 »

I am trying to calculate a suggested value for an entry field. The specific value I am looking for is the total number of bytes a storage device can hold.

A program "blockdev --getsize64 /dev/XXXX" will get the value for me. The sticky part is that I will not know the "/dev/xxxx" value until the user selects it.

The snippet below produces a list that the user selects from. The selection identifies the drive I want to determine the size of, in bytes.

Code: Select all

<list>
       <width>150</width>
       <height>80</height>
       <variable>EWF_SusPDrv</variable>
       <input>find /dev -type b -exec echo '{}' \; | sort </input></list>
</list>
I want to use the output from blockdev --getsize64 $EWF_SusPDrv to get that number.

Code: Select all

<text xalign="0" width-request="200"><label>"Number of Bytes to acquire"</label></text>
<entry width-request="100">
       <default>0</default>
       <variable>EWF_B</variable>
       <input>0</input>
</entry>
I could really use suggestions, thoughts, hints.

Thanks in advance guys

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

#1228 Post by SFR »

Hey Slippery60, try this:

Code: Select all

#!/bin/sh

export MAIN='
<window>
  <vbox>
    <list> 
       <width>150</width> 
       <height>80</height> 
       <variable>EWF_SusPDrv</variable> 
       <input>find /dev -type b | sort </input>
       <action>refresh:EWF_B</action>
	</list>
    
    <text xalign="0" width-request="200"><label>"Number of Bytes to acquire"</label></text> 
	<entry width-request="100"> 
       <variable>EWF_B</variable> 
       <input>[ $EWF_SusPDrv ] && blockdev --getsize64 $EWF_SusPDrv || echo "N/A"</input> 
	</entry>
  </vbox>
</window>'

gtkdialog -p MAIN
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
spiritwild
Posts: 181
Joined: Mon 03 Oct 2016, 10:06

#1229 Post by spiritwild »

question...

I'm not someone who can put all the gtk code together to make what I want. I could take a simple app like what I need and possibly edit it to my likes. Is there a simple "menu" app / code that I could mess with?

It basically just needs to be a small window with buttons that I can run programs from. Combine a few apps to one menu, so to speak.
I'm just not familiar so if theres a simple code or app I could mess around with, that would be helpful. Thanks

slippery60
Posts: 5
Joined: Mon 18 Dec 2017, 20:31
Location: Fairmont, WV

How to calculate an suggested value for an entry widget

#1230 Post by slippery60 »

SFR;

Thanks Dude, exactly what I needed.

Fantastic.

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

#1231 Post by don570 »

It basically just needs to be a small window with buttons that I can run programs from.
People on the forum have already written this...

http://murga-linux.com/puppy/viewtopic.php?t=61962
http://murga-linux.com/puppy/viewtopic.php?t=76713

____________________________________________

To make a quick launcher yourself...

Put links to the desktop files in one folder,
then you can open this folder with the command

Code: Select all

rox -d /path/to/folder
__________________________________________

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

Launch pmusic in a script

#1232 Post by don570 »

Launch pmusic in a script
I have found that it is difficult to launch pmusic inside a script.

Here is method that works reliably even when pmusic has an option.
First of all , choose pmusic from other apps

Code: Select all

for P in mpg123 mpg321  pmusic parole vlc  xine defaultaudioplayer ; do
  MUSIC_APP=$(which $P) && break
done
Now replace pmusic with 'pmusic -B' if you want background music.
Put the command in a file and make executable.

Code: Select all

[ $MUSIC_APP = /usr/local/bin/pmusic ] && MUSIC_APP="pmusic -B"
echo "$MUSIC_APP" \""${snd}"\" > /tmp/pmusic_launch
chmod +x /tmp/pmusic_launch
/tmp/pmusic_launch 2>/dev/null &
_________________________________________________________

I used this method in PTM timer
http://murga-linux.com/puppy/viewtopic.php?t=112410
_________________________

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: Launch pmusic in a script

#1233 Post by MochiMoppel »

don570 wrote:Here is method that works reliably even when pmusic has an option.
First of all , choose pmusic from other apps

Code: Select all

for P in mpg123 mpg321  pmusic parole vlc  xine defaultaudioplayer ; do
  MUSIC_APP=$(which $P) && break
done
Now replace pmusic with 'pmusic -B' if you want background music.
Put the command in a file and make executable.

Code: Select all

[ $MUSIC_APP = /usr/local/bin/pmusic ] && MUSIC_APP="pmusic -B"
echo "$MUSIC_APP" ""${snd}"" > /tmp/pmusic_launch
chmod +x /tmp/pmusic_launch
/tmp/pmusic_launch 2>/dev/null &
Try

Code: Select all

for MUSIC_APP in mpg123 mpg321  pmusic parole vlc  xine defaultaudioplayer ; do 
   which $MUSIC_APP && break 
done 
[ $MUSIC_APP = pmusic ] && OPTION="-B" 
exec $MUSIC_APP $OPTION "$snd"

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

#1234 Post by don570 »

[ $MUSIC_APP = pmusic ] && OPTION="-B"
exec $MUSIC_APP $OPTION "$snd"
I hadn't thought of that. I was trying to do it all as one variable
MUSIC_APP="pmusic -B"
________________________________

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1235 Post by MochiMoppel »

don570 wrote:I hadn't thought of that. I was trying to do it all as one variable
MUSIC_APP="pmusic -B"
...which would work perfectly - unless you have unintentionally changed your IFS assignment :wink:

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

#1236 Post by don570 »

I noticed that someone has put up a good page with examples to
explain gtkdialog
http://xpt.sourceforge.net/techdocs/lan ... gExamples/
__________________________________________________

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

Example to show opening a second window

#1237 Post by don570 »

Thunor has given us examples of gtkdialog in action.
http://murga-linux.com/puppy/viewtopic.php?t=82059
In the miscelaneous section there is an example showing the launch of
a second window. I wanted the second window to close at the same time
as the main window. Check this by clicking on 'Quit' button' in main window.

I find this is good for a system of help or a logging function which
uses the second window. As an example see my PTM timer
where the 'Log' button keeps track of previous events.

Thunor's script is rather complicated so I have simplified it.

Code: Select all

#!/bin/sh
#example to show launching of second window

# Please note that the name of the exported shell variable matches the
# window widget's variable directive which is a requirement. Not doing
# this will result in the launching of duplicate windows none of which
# can be closed and a warning message being sent to the terminal.




winMain='
<window title="winMain" width-request="250">
	<vbox>
		<frame>		<button>
				<label>launch winLaunch1</label>
				<action function="launch">winLaunch1</action>
			</button>
			<button>
				<label>closewindow winLaunch1</label>
				<action function="closewindow">winLaunch1</action>
			</button>
		</frame>
		
		
		<hbox homogeneous="true">
			<button use-stock="true" label="gtk-quit"></button>
		</hbox>
	</vbox>
	<variable>winMain</variable>
</window>
'
export winMain

winLaunch1='
<window title="winLaunch1" width-request="250">
	<vbox>
		<text><label>text label</label></text>
		<hbox homogeneous="true">
		<button>
				<label>closewindow</label>
				<action function="closewindow">winLaunch1</action>
			</button>
		
			<button use-stock="true" label="gtk-quit"></button>
		</hbox>
	</vbox>
	<variable>winLaunch1</variable>
</window>
'
export winLaunch1
 I=$IFS; IFS=""
     for STATEMENTS in  $(gtkdialog -p winMain); do
       eval $STATEMENTS        
     done
#gtkdialog --program=winMain
xmessage  "I am here"

Attachments
screenshot-multiple-windows.png
(29.19 KiB) Downloaded 605 times

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#1238 Post by BarryK »

Oh joy, I have just discovered this, to show/hide a hbox or vbox:
How to change the gui without restarting the app
>> Recent Gtkdialog allows to hide/show widgets, To hide many widgets at once, you can hide a <hbox> or <vbox>. This will hide all widgets inside the box.
Works real nice.

I have a question though, about this show and hide. I can click on a button, for example, to show/hide a hbox:

Code: Select all

<hbox>
 ...widgets...
 <variable>BOX1</variable>
</hbox>

<button>
 <label>hide</label>
 <action function="hide">BOX1</action>
</button>
But, how can I have it so that BOX1 is hidden by default when the window starts up?

EDIT:
Ha ha, have answered my own question!
I just experimented, this works:

Code: Select all

<hbox visible="false">
 ...widgets...
 <variable>BOX1</variable>
</hbox>

<button>
 <label>show</label>
 <action function="show">BOX1</action>
</button>
There is a problem with window resizing, after doing a "show" then a "hide" again (with a "hide" button) -- the window stays bigger, with a gap in it.
[url]https://bkhome.org/news/[/url]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1239 Post by MochiMoppel »

BarryK wrote:There is a problem with window resizing, after doing a "show" then a "hide" again (with a "hide" button) -- the window stays bigger, with a gap in it.
May not be obvious, but works:

Code: Select all

<window resizable="false"....
BTW: Another way to hide BOX1 is to add an action to the window widget (instead of adding visible="false" to the hbox):

Code: Select all

<action signal="show">hide:BOX1</action>
This is the only method I know to hide/show a widget at start up conditionally. E.g. you may want to show BOX1 only when a certain application is installed or a flag is set.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#1240 Post by BarryK »

MochiMoppel,
Thanks for the reply.

Setting resizable="false" does not fix it for me.

Thanks for the alternative way of setting default hiding.

I have another little problem with window wrapping around the widgets.

This is pretty simple code;

Code: Select all

<window title="EasyShare" icon-name="gtk-network" resizable="false">
 <vbox>
  <text use-markup="true"><label>"<b>Share files and printers over a local network</b>"</label></text>
  
  <hbox>
   <text width-chars="25"><label>CUPS is enabled in the firewall, so a local printer can be accessed by other computers.</label></text>
   <text width-chars="25"><label>Firewall enabled for sharing local files and remote files.</label></text>
   <vbox>
    <pixmap>
     <width>56</width>
     <input file>/tmp/easyshare-1.svg</input>
    </pixmap>
    <button>
     <label>Firewall Setup</label>
     <action function="exit">firewall</action>
    </button>
   </vbox>
   <variable>BOX_FIREWALL</variable>
  </hbox>
 
  <hseparator></hseparator>
  <hbox>
   <button><label>Exit</label><action function="exit">quit</action></button>
  </hbox>
 </vbox>
</window>
As soon as I inserted that hbox section, the window rendered with a big gap on the left side. See picture.

Has anyone encountered this, and know how to fix it?
Attachments
gtkdialog-test1.png
(12.86 KiB) Downloaded 531 times
[url]https://bkhome.org/news/[/url]

Post Reply