Liam,

 

Thanks for the prompt reply.  That is working for me.

 

Regards,

 

John,

 

-----Original Message-----
From: Liam Clarke [mailto:[EMAIL PROTECTED]
Sent: 07 May 2006 13:06
To: [EMAIL PROTECTED]
Cc: tutor@python.org
Subject: Re: [Tutor] Button Signals

 

Hi John,

I'll answer your questions, but first: Pythoncard is for wxPython. wxPython is vastly different to PyGTK afaik.

The docs you quote answer your question:

The return value from a connect () call is an integer tag that identifies your callback. As stated above, you may have as many callbacks per signal and per object as you need, and each will be executed in turn, in the order they were attached.

This tag allows you to remove this callback from the list by using:

  object.disconnect(id)

So, by passing in the tag returned by one of the signal connect methods, you can disconnect a signal handler.


Your code needs the following:

        self. callback_id1 = process.connect("clicked", self.callback1, start_date, process)

 

def callback1(self,data,start_date,process ):

            process.disconnect(self.callback_id1)

 

 

 

 

 

On 5/7/06, John CORRY < [EMAIL PROTECTED]> wrote:

Hi,

 

I am having difficulty with using signal handlers.  I am using Glade 2 and Pygtk.  My editor is Pythoncard.  The following code connects to button one and calls a function which hides button one.  

 

self.wTree = gtk.glade.XML ("phonelog.glade", "window1")

        dic={"on_window1_destroy" : self.quit, }

        self.wTree.signal_autoconnect (dic)

       

       

        process = self.wTree.get_widget("button1")

        process.connect("clicked", self.callback1, start_date, process)

 

def callback1(self,data,start_date,process ):

            process.hide()

 

The above code works fine.  However I want button one to remain on my GUI.  Thus, I want to just stop the signal being emitted after it is pressed once.  I have used the following code which is trying to disconnect the button one:

 

self.wTree = gtk.glade.XML ("phonelog.glade", "window1")

        dic={"on_window1_destroy" : self.quit, }

        self.wTree.signal_autoconnect (dic)

       

       

        process = self.wTree.get_widget("button1")

        process.connect("clicked", self.callback1, start_date, process)

 

def callback1(self,data,start_date,process ):

            process.disconnect()

 

When I run this code I get the error

TyoeError:  Object takes exactly one argument(0 given)

 

When I put an argument in, it says that the argument must be an integer.  I have tried a number of integers at random but none work.  On the Pygtk tutorial it states the following:

 

3.1. More on Signal Handlers

Lets take another look at the connect() call.

  object.connect(name, func, func_data)

The return value from a connect() call is an integer tag that identifies your callback. As stated above, you may have as many callbacks per signal and per object as you need, and each will be executed in turn, in the order they were attached.

This tag allows you to remove this callback from the list by using:

  object.disconnect(id)

So, by passing in the tag returned by one of the signal connect methods, you can disconnect a signal handler.

How do I find out what the integer tag is, so that I can put this in my code?

 

I have tried the pygtk faq page but it is currently unavailable.

 

Any help greatly appreciated.

 

Thanks,

 

John.

 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

 

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to