Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 20 Dec 2014, 17:02
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Gtkdialog not calling function
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
gary101


Joined: 08 Oct 2006
Posts: 539
Location: Boston, Lincs. UK

PostPosted: 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
View user's profile Send private message 
ljfr

Joined: 23 Apr 2009
Posts: 176

PostPosted: 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
View user's profile Send private message 
gary101


Joined: 08 Oct 2006
Posts: 539
Location: Boston, Lincs. UK

PostPosted: 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 Very Happy

Tanks again

Gary

_________________
If it's not one thing it's your mother
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

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.0520s ][ Queries: 11 (0.0035s) ][ GZIP on ]