Gtkdialog not calling function

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
gary101
Posts: 555
Joined: Sun 08 Oct 2006, 09:51
Location: Boston, Lincs. UK

Gtkdialog not calling function

#1 Post by gary101 »

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: Select all

#!/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

ljfr
Posts: 176
Joined: Thu 23 Apr 2009, 08:35

export and unset

#2 Post by ljfr »

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: Select all

#!/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

User avatar
gary101
Posts: 555
Joined: Sun 08 Oct 2006, 09:51
Location: Boston, Lincs. UK

#3 Post by gary101 »

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 :D

Tanks again

Gary
If it's not one thing it's your mother

Post Reply