Ahau Thanks for posting code to share !
here's an update on toggling a pixmap image ,button and entry
gtkdialog is a static GUI so much trickery involved to get it to look like a dynamic GUI
meaning updating the GUI when its running
the pixmap took me awhile to figure out so don't feel bad if
it takes you some time to get a working example going
it starts to make sense after the dizzy feeling goes away from following all the zig-zags
*required images * place in the same directory as the script
http://bigbass-porteus.googlecode.com/files/ok-orig.png
http://bigbass-porteus.googlecode.com/files/ok.png
http://bigbass-porteus.googlecode.com/files/cancel.png
http://bigbass-porteus.googlecode.com/files/no.png
http://bigbass-porteus.googlecode.com/files/yes.png
Code: Select all
#!/bin/sh
# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/).
# March 27 2012 btnImage and lable Toggle bigbass modified example added
# entry label and default start
# March 29 -2012 added pixmap function
# /tmp/ replaced with /dev/shm/ for guest account permissions problems
# required images in the same directory as the script
# ok-orig.png ,cancel.png ,ok.png,yes.png,no.png
#http://bigbass-porteus.googlecode.com/files/ok-orig.png
#http://bigbass-porteus.googlecode.com/files/ok.png
#http://bigbass-porteus.googlecode.com/files/cancel.png
#http://bigbass-porteus.googlecode.com/files/no.png
#http://bigbass-porteus.googlecode.com/files/yes.png
# set up default start or stop here
# what GAMES TO PLAY to make static gtkdialog 'pretend to be dynamic'
echo "click button to stop first run" >$PWD/LABLE.txt
echo 0 > TOGGLE
ln -sf no.png toggle.png
cp -f $PWD/ok-orig.png /dev/shm/ok.png
# we have to always start with the cancel image
# or you would have to click once with no changes
# because you would have two ok's in a row
cp -f $PWD/cancel.png $PWD/ok.png
#--------------------------------------------------
# small button image next to entry yes and no .png
#--------------------------------------------------
function funcImageToggle() {
if [ $(< TOGGLE) = 1 ]; then
ln -sf no.png toggle.png
echo 0 > TOGGLE
echo "click button to stop function" >$PWD/LABLE.txt
else
ln -sf yes.png toggle.png
echo 1 > TOGGLE
echo "click button to start function" >$PWD/LABLE.txt
fi
}
export -f funcImageToggle
if [ ! -f TOGGLE ]; then echo 0 > TOGGLE; funcImageToggle; fi
#--------------------------------------------------
# PIXMAP image cancel and ok .png
#--------------------------------------------------
function funcPixmapToggle() {
if [ $(< TOGGLE2) = 1 ]; then
# copy file to tmp so we dont over write the original
cp -f $PWD/ok.png /dev/shm/ok.png
# overwrite file now cancel=ok
cp -f $PWD/cancel.png $PWD/ok.png
echo 0 > TOGGLE2
else
# return the original ok ok=ok
cp -f $PWD/ok-orig.png $PWD/ok.png
echo 1 > TOGGLE2
fi
}
export -f funcPixmapToggle
if [ ! -f TOGGLE2 ]; then echo 0 > TOGGLE2; funcPixmapToggle; fi
export MAIN_DIALOG='
<window title="btnImage and lable Toggle + pixmap toggle" resizable="false" width-request="390" height-request="100">
<vbox homogeneous="true">
<pixmap>
<variable>IMAGE</variable>
<input file>'"$PWD"'/ok.png</input>
</pixmap>
<button tooltip-text="change pixmap image " resizable="false" height-request="40">
<label>Change image</label>
<action>funcPixmapToggle</action>
<action type="refresh">IMAGE</action>
</button>
<hbox homogeneous="true">
<entry>
<variable>ENTRY</variable>
<input>cat $PWD/LABLE.txt</input>
<variable>ENTRY</variable>
</entry>
<button tooltip-text="click button for on or off !">
<action>cat $PWD/LABLE.txt</action>
<variable>TOGGLEMETOO</variable>
<input file>toggle.png</input>
<action>funcImageToggle</action>
<action type="refresh">TOGGLEMETOO</action>
<action type="refresh">ENTRY</action>
</button>
</hbox>
</vbox>
<action signal="hide">exit:Exit</action>
</window>
'
gtkdialog --center --program=MAIN_DIALOG
Posted after 2 days 19 hours 52 minutes 34 seconds:
txt2image in gtkdialog
http://porteus.org/forum/viewtopic.php? ... 8802#p8802
Posted after 5 days 8 hours 43 minutes 21 second:
menu item example
Remember I am looking for code tested to be working on Porteus
if you have some snippets
place this logo in /usr/share/icons
http://bigbass-porteus.googlecode.com/f ... k-logo.png
Code: Select all
#!/bin/bash
# SIMPLE_MENU
# Example code using menuitem
# For Porteus 1.2 by bigbass
export SIMPLE_MENU='
<window title="Simple Menu" window-position="1">
<vbox>
<menubar>
<menu>
<menuitem icon="gpicview"> <label>Image Viewer</label> <action>gpicview &</action> <action>exit</action> </menuitem>
<menuitem icon="noatun"> <label>Noatun</label> <action>noatun %i %m -caption "%c" %U &</action><action>exit</action> </menuitem>
<menuitem icon="gnome-mplayer"> <label>GNOME MPlayer</label> <action>gnome-mplayer &</action><action>exit</action> </menuitem>
<menuitem icon="leafpad"> <label>Leafpad</label> <action>leafpad &</action><action>exit</action></menuitem>
<menuitem icon="firefox"> <label>Firefox</label> <action>firefox &</action><action>exit</action> </menuitem>
<menuitem icon="lxterminal"> <label>Super User Mode - Terminal</label> <action>/tmp/.terminal -e su - &</action><action>exit</action> </menuitem>
<menuitem icon="xarchiver"> <label>Xarchiver</label> <action>xarchiver &</action><action>exit</action> </menuitem>
<menuitem icon="lxtask"> <label>Task Manager</label> <action>lxtask &</action><action>exit</action> </menuitem>
<menuitem icon="gparted"> <label>GParted</label> <action>gparted &</action><action>exit</action> </menuitem>
<label>Programs</label>
</menu>
<menu>
<menuitem icon="status_unknown"> <label>Porteus System Info</label> <action>/tmp/.terminal -e /opt/porteus-scripts/psinfo &</action><action>exit</action> </menuitem>
<menuitem icon="pmodule"> <label>Porteus Package Manager</label> <action>/tmp/.terminal -e "ktsuss /opt/porteus-scripts/porteus-package-manager" &</action><action>exit</action> </menuitem>
<menuitem icon="drive-external-usb"> <label>Porteus Installer</label> <action>/tmp/.terminal -e "ktsuss /opt/porteus-scripts/pinstaller" &</action><action>exit</action> </menuitem>
<label>Special</label>
</menu>
<menu>
<menuitem icon="firefox"> <label>Porteus.org</label> <action>firefox http://porteus.org/ &</action><action>exit</action> </menuitem>
<menuitem icon="firefox"> <label>Porteus download stuff</label> <action>firefox http://ponce.cc/porteus/ &</action><action>exit</action> </menuitem>
<menuitem icon="kfind"> <label>Porteus FAQ</label> <action>/tmp/.browser /usr/doc/Porteus-FAQ/index.html &</action><action>exit</action> </menuitem>
<label>Help</label>
</menu>
</menubar>
<frame>
<pixmap>
<input file>/usr/share/icons/black-logo.png</input>
</pixmap>
<text><label>Simple menu for Porteus</label></text>
</frame>
<hbox>
<button cancel></button>
</hbox>
</vbox>
</window>'
gtkdialog --program SIMPLE_MENU
unset SIMPLE_MENU
Posted after 4 days 5 hours 23 minutes 37 seconds:
this is how to think when using gtkdialog
I hated gtkdialog before for the reason it looks odd to read
and stayed away from it after a little practice it becomes easy to read
The first thing you need to see is how the code is grouped in blocks like legos
1.) The light blue is the head and foot
2.) The yellow is in this example the start and end of the body everything else is between this
3.) The grey in this example the text starts and ends and the lable is what shows in the GUI
4.)The orange is a simple double button one is ok the other is cancel it starts with a hbox in this example

sometimes you want things horizonal that's hbox
sometimes you want things vertical that's vbox
the faster you see how the code is grouped the faster you can add and remove code
in blocks this is the first hurdle when reading gtkdialog
that thought led me to start developing a syntax high lighting tool for gtkdialog more to come !
http://porteus.org/forum/viewtopic.php?f=94&t=1177