gtkdialog getting started
bigbass
Re: gtkdialog getting started
Post#17 by bigbass » 28 Nov 2012, 16:18
Code: Select all
#!/bin/bash
# description of script:
# control Modem service on and off
# script name modem_control
# Nov 28,2012 Joe Arose "bigbass"
# this is an administrative script
# written to show what is happening with the service
# without obscuring the processes involved
# keeping everything transparent
rm /tmp/modem_status
# lets run this first to get the modem status before gtkdialog is run
ps -A| grep dhcpcd > /dev/null 2>&1 ;RETVAL=${PIPESTATUS[1]};[ $RETVAL -eq 0 ] && RESULT_="Modem running";[ $RETVAL -ne 0 ] && RESULT_="Modem not running"
echo $RESULT_ >/tmp/modem_status
export MODEM_DIALOG='
<window title="Modem Service Control">
<vbox>
<frame Start / stop modem>
<pixmap icon_size="6">
<input file stock= "gtk-connect"></input>
</pixmap>
</frame>
<frame Wait on status to change... >
<entry>
<input file>/tmp/modem_status</input>
<variable>ENTRY</variable>
</entry>
</frame>
<frame "Enable" starts modem "Disable" stops modem >
<hbox>
<button>
<label>Enable</label>
<action type="enable">ENTRY</action>
<action type="enable">CHECKBOX</action>
<action>/sbin/dhcpcd </action>
<action>ps -A| grep dhcpcd > /dev/null 2>&1 ;RETVAL=${PIPESTATUS[1]};[ $RETVAL -eq 0 ] && RESULT_="Modem running";[ $RETVAL -ne 0 ] && RESULT_="Modem not running" ;echo Modem running >/tmp/modem_status </action>
<action type="refresh">ENTRY</action>
</button>
<button>
<label>Disable</label>
<action type="enable">ENTRY</action>
<action type="enable">CHECKBOX</action>
<action>/sbin/dhcpcd -x</action>
<action>ps -A| grep dhcpcd > /dev/null 2>&1 ;RETVAL=${PIPESTATUS[1]};[ $RETVAL -eq 0 ] && RESULT_="Modem running";[ $RETVAL -ne 0 ] && RESULT_="Modem not running" ;echo Modem not running >/tmp/modem_status </action>
<action type="refresh">ENTRY</action>
</button>
</hbox>
</frame>
<hbox>
<button cancel></button>
</hbox>
</vbox>
</window>
'
gtkdialog --center --program MODEM_DIALOG
*I have a binary I wrote to convert spaces to tabs and justify text
called 2tabs written in BaCon I used to allow for code indentation in this post
IMAGE

I wrote this for gtkdialog so we have some easy examples
This example shows how to control back end services that may or not be running
*Will port this to BaCon too
Sometimes I forget to turn on my modem and when booting slackware 14 it times out
and as a result I don't have internet using LAN so this is a quick way my kids and I can check if the modem is working
A GUI is nice to have to make things easy
Joe
bigbass
Re: gtkdialog getting started
Post#18 by bigbass » 15 Feb 2013, 16:28
http://bigbass-porteus.googlecode.com/f ... lack14.tgz
Joe
bigbass
- freestyler
- Contributor
- Posts: 384
- Joined: 17 Oct 2013, 14:21
- Distribution: Porteus XFCE
Re: gtkdialog getting started
Post#19 by freestyler » 05 Mar 2014, 04:27
Code: Select all
kdialog --getopenfilename /etc/openvpn/. "*.ovpn"
Ive searched the internet all day and the closest I got was by using zenity.
freestyler
- brokenman
- Site Admin
- Posts: 6105
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
Re: gtkdialog getting started
Post#20 by brokenman » 06 Mar 2014, 01:26
Code: Select all
#!/bin/bash
echo '<window title="'$(gettext "Open a file")'" icon-name="gtk-open" width-request="350">
<vbox>
<text><label>Please select a file:</label></text>
<hbox>
<entry fs-action="file"
fs-title="Select a file"
fs-filters="*.'$2'"
fs-folder="'$1'"
editable="false">
<variable>entselFile</variable>
</entry>
<button space-expand="false" space-fill="false">
<label>Select</label>
<variable>butselFile</variable>
<action function="fileselect">entselFile</action>
</button>
</hbox>
</vbox>
</window>
'|gtkdialog -s -c
You can also place it in a function in your existing script and just call the function. Something like:
Code: Select all
choose_file(){
place_above_code_in_here
}
choose_file /etc/openvpn ovpn
Wear your underpants on the outside and put on a cape.
brokenman
- freestyler
- Contributor
- Posts: 384
- Joined: 17 Oct 2013, 14:21
- Distribution: Porteus XFCE
Re: gtkdialog getting started
Post#21 by freestyler » 06 Mar 2014, 23:22
I'm now having problems calling a function. It says:
Code: Select all
sh: term: command not found
Code: Select all
function term(){
exec xterm -e "openvpn --config $entselFile"
}
Code: Select all
<button>
<label>Start</label>
<action>term</action></button>
<button>
freestyler
- freestyler
- Contributor
- Posts: 384
- Joined: 17 Oct 2013, 14:21
- Distribution: Porteus XFCE
Re: gtkdialog getting started
Post#22 by freestyler » 07 Mar 2014, 01:22
Code: Select all
export -f term
freestyler
-
- Full of knowledge
- Posts: 428
- Joined: 02 Jan 2011, 18:41
- Distribution: Porteus v5.01.....PorteuX v1.4
- Location: In the bush now
Re: gtkdialog getting started
Post#23 by roadie » 22 Mar 2014, 20:48
It's on 32bit Porteus-Kde v3.0
guest@porteus:~$ gtkdialog
** (gtkdialog:3266): ERROR **: Gtkdialog: Could not find the dialog description in the environment variable 'MAIN_DIALOG'.
Trace/breakpoint trap
Does gtkdialog need to be called with a file option?
Yes, I'm new to Gtkdialog...finding lots of examples online, but very little about the program itself.
roadie
- brokenman
- Site Admin
- Posts: 6105
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
Re: gtkdialog getting started
Post#24 by brokenman » 23 Mar 2014, 23:59
http://murga-linux.com/puppy/viewtopic.php?t=38608
Wear your underpants on the outside and put on a cape.
brokenman
-
- Shogun
- Posts: 204
- Joined: 29 Dec 2010, 08:10
- Distribution: porteus v5.0-xfce K5.19.7
- Location: France
gtkdialog getting started
Post#25 by bour59 » 28 Sep 2022, 09:49
Here is my script
Code: Select all
Detect()
{ for item in Pomme Poire Abricot Prune Raisin
do echo $item ; done }
mainDialog()
{
TITLE="Choose a fruit "
FRUIT_FRAME="Select a fruit from available list"
FRUIT_NAME="Name of the fruit"
/bin/rm -f /tmp/fruits
Detect >> /tmp/fruits
local DIALOG='
<window title="'$TITLE'"> <vbox>
<frame '$FRUIT_FRAME'>
<table>
<width>60</width> <height>120</height>
<label>'$FRUIT_NAME'</label>
<input file>/tmp/fruits</input>
<variable>MY_FRUIT</variable>
</table>
</frame>
<hbox> <button ok></button> <button cancel></button> </hbox>
</vbox> </window> '
echo "$DIALOG" | sed '/^##/d'| gtkdialog -c -s 2> /dev/null
}
eval "`mainDialog`"
echo $MY_FRUIT" is selected"</code>
bour59
- ncmprhnsbl
- DEV Team
- Posts: 4291
- Joined: 20 Mar 2012, 03:42
- Distribution: v5.0-64bit
- Location: australia
- Contact:
gtkdialog getting started
Post#26 by ncmprhnsbl » 28 Sep 2022, 12:54
this is because Porteus5.0 gtkdialog is built with/for gtk+3 (and APorteus is still using gtk+2 version)
"table" was deprecated in gkt+2 and then removed in gtk+3
but
you can use "tree" in the same way:
Code: Select all
Detect()
{ for item in Pomme Poire Abricot Prune Raisin
do echo $item ; done }
mainDialog()
{
TITLE="Choose a fruit "
FRUIT_FRAME="Select a fruit from available list"
FRUIT_NAME="Name of the fruit"
/bin/rm -f /tmp/fruits
Detect >> /tmp/fruits
local DIALOG='
<window title="'$TITLE'"> <vbox>
<frame '$FRUIT_FRAME'>
<tree>
<width>60</width> <height>120</height>
<label>'$FRUIT_NAME'</label>
<input file>/tmp/fruits</input>
<variable>MY_FRUIT</variable>
</tree>
</frame>
<hbox> <button ok></button> <button cancel></button> </hbox>
</vbox> </window> '
echo "$DIALOG" | sed '/^##/d'| gtkdialog -c -s 2> /dev/null
}
eval "`mainDialog`"
echo $MY_FRUIT" is selected"
ncmprhnsbl