The time now is Sun 19 May 2013, 22:15
All times are UTC - 4 |
| Author |
Message |
gary101

Joined: 08 Oct 2006 Posts: 539 Location: Boston, Lincs. UK
|
Posted: Tue 02 Feb 2010, 03:40 Post subject:
Gtkdialog not calling function Subject description: Help! |
|
Hi
I have just started trying my hand with gtkdialog
Could someone please give me some advice please?
My script has a function called WatchNow but it is not being called from the button action. I have tried the function as a stand alone and it works fine, I have also tried substituting other functions from scripts that I know are working but with the same result, the function is not being called.
It is probably some thing very simple but is driving me mad. HELP!!!!
Code is below, thanks for looking
Gary
| Code: | #!/bin/bash
function WatchNow()
{
mplayer dvb://Dave
}
Test
MAIN_DIALOG='
<window title="pDVB">
<vbox>
<frame Select Player >
<vbox>
<hbox>
<text>
<label>Player:</label>
</text>
<combobox>
<variable>PLAYER</variable>
<item>Mplayer</item>
<item>Gxine</item>
</combobox>
</hbox>
</vbox>
<vbox>
<table>
<width>150</width><height>200</height>
<variable>TABLE</variable>
<label>Channels:</label>
<item>First item </item>
<item>Second item</item>
<item>Third item </item>
<action>echo $TABLE</action>
</table>
<hbox>
<button>
<label>Watch</label>
<action>Test</action>
</button>
</hbox>
</vbox>
</frame>
<hbox>
<button>
<action>exit:EXIT</action>
</button>
</hbox>
</vbox>
</window>
' gtkdialog3 --program=MAIN_DIALOG
|
_________________ If it's not one thing it's your mother
|
|
Back to top
|
|
 |
ljfr
Joined: 23 Apr 2009 Posts: 176
|
Posted: Tue 02 Feb 2010, 04:42 Post subject:
export and unset |
|
Hi gary,
You need to export (and unset) what you want to use with gtkdialog,
If necessary, have a look at the topic "GtkDialog - tips" in the How-to section of this forum.
regards,
| Code: | #!/bin/bash
function WatchNow()
{
#first argument: player to be used, default to mplayer
[[ $1 ]] && my_player="$1" || my_player="mplayer"
#second argument: media to be used, default to dvb://Dave
[[ $2 ]] && my_media="$2" || my_media="dvb://Dave"
exec "$1" "$2"
}
MAIN_DIALOG='
<window title="pDVB">
<vbox>
<frame Select Player >
<hbox>
<text>
<label>Player:</label>
</text>
<combobox>
<variable>PLAYER</variable>
<item>mplayer</item>
<item>gxine</item>
</combobox>
</hbox>
<table>
<width>150</width><height>200</height>
<variable>TABLE</variable>
<label>Channels:</label>
<item>dvb://Dave</item>
<item>dvb://Dave</item>
<item>dvb://Dave</item>
<action>echo $TABLE</action>
</table>
<button>
<label>Watch</label>
<action>WatchNow $PLAYER $TABLE</action>
</button>
</frame>
<button cancel></button>
</vbox>
</window>
'
export MAIN_DIALOG
export -f WatchNow
gtkdialog3 --program=MAIN_DIALOG
unset MAIN_DIALOG
unset -f WatchNow |
|
|
Back to top
|
|
 |
gary101

Joined: 08 Oct 2006 Posts: 539 Location: Boston, Lincs. UK
|
Posted: Thu 04 Feb 2010, 03:36 Post subject:
|
|
Thanks ljfr
That work perfectly, I will have to spend a bit of time to see the flow of the variables are passed but having this example will make it so much easier.
The next task after getting the rest of my functions to work properly will be to import the list of valid channels from a text file to the frame.
It all keeps me out of trouble
Tanks again
Gary
_________________ If it's not one thing it's your mother
|
|
Back to top
|
|
 |
|
|
|
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.0454s ][ Queries: 12 (0.0034s) ][ GZIP on ] |