Re: pyGTK identify a button



the two button are connected (when clicked) to infoButton(self,
widget,
data=None)

From documentation:
handler_id = object.connect(name, func, func_data)

So:

button1.connect(when is pressed, your_function, 1)
button2.connect(when is pressed, your_function, 2)
(This code is conception, I don't really know how is done in GTK).

On the callback:
infoButton(self, widget, data=None):
# discover wich button was pressed
...
# say hello to the button
if data == 1:
print "Hi, button1!"
else:
print "Hi, button2!"

--
Claudiu Nicolaie CISMARU
GNU GPG Key: http://claudiu.targujiu.net/key.gpg
T: +40 755 135455
E: claudiu@xxxxxxxxxxxxxxx, claudiu.cismaru@xxxxxxxxx

Attachment: signature.asc
Description: This is a digitally signed message part.



Relevant Pages

  • Re: pyGTK identify a button
    ... way to identify wich button is pressed. ... the two button are connected to infoButton(self, widget, ... print "Hi, button1!" ... without reading the label of the button (i could have buttons with the ...
    (comp.lang.python)
  • Re: pyGTK identify a button
    ... On 25/05/2011 10:44, Claudiu Nicolaie CISMARU wrote: ... handler_id = object.connect(name, func, func_data) ... know how to set it on glade3.8, that is the program i use to create the GUI. ...
    (comp.lang.python)