gtk event handler

Guillaume Rumeau guillaume.rumeau at wanadoo.fr
Thu Jul 4 11:26:36 EDT 2002


Hi,

Please excuse me if I'm out of topic (but I don't think so).

I would like to have a handler-function common for a lot of widgets
(buttons).
But my problem is I would like to know what widget produce the event I
caught.

For example, I have a handler-function :

def on_button_clicked (source = None, event = None) :
    print "Button pressed"
    print str(source), dir(source)
    print str(source._o), dir(source._o)
    print str(event), dir(event)

When any of the button are clicked, the result is that :

Button pressed
<gtk.GtkButton instance at 0x823e40c> ['_o']
<GtkObject of type GtkButton at 822fca8> []
None []


My problem is I would like to have the reference to the button wich
was clicked to make the adequat treatment, for example to change the
label.

I have probably missed something, but I don't see what (of course).
Could you help me or let me pointed over the doc ?

I know a bit more Tkinter, but not much gtk-python.
Thank you for helping.

-- 
GR <guillaume.rumeau at wanadoo.fr>



More information about the Python-list mailing list