On Wed, 25 May 2011 10:18:48 +0200, Tracubik wrote: > Hi all, > i'm trying to write a simple windows with two button in GTK, i need a > way to identify wich button is pressed. Consider that: > > the two button are connected (when clicked) to infoButton(self, widget, > data=None) > > infoButton() is something like this > > infoButton(self, widget, data=None): > # discover wich button was pressed > ... > # say hello to the button > if button1pressed: > print "Hi, button1!" > else: > print "Hi, button2!" > > so, how can I know wich button was pressed without using data and > without reading the label of the button (i could have buttons with the > same label) > > If data is needed, can someone pls tell me how to set it properly in > glade 3.8 > > thanks > Nico
This looks similar to a question I posted about 2 weeks ago In gtk 2.1.6 (i think) & earlier you could use widget.get_name() to return the id of the widget. this no-longer works since 2.1.7 the pygtk forum suggests this is because widget id's are not necessarily unique & caused problems elsewhere, to be honest most of the explanation went above my head. I did find a work around & that was to use gtk.buildable.get_name(widget) but is is probably cleaner to use a discrete callback for each button. -- Disco is to music what Etch-A-Sketch is to art. -- http://mail.python.org/mailman/listinfo/python-list