[pygtk] Confused about a widget's name
Skip Montanaro
skip at pobox.com
Fri Apr 26 01:59:25 WST 2013
I'm returning to PyGTK programming after a long hiatus. When last I
visited these waters, I used Gtk 2.12. Now I use 2.22 and this
Builder thing, which, I must admit, has me a bit confused.
In a signal callback for a radio button, if I ask for its name
(rb.get_name()) I always get "GtkRadioButton". If I call get_property
with "name" as the argument, I get the empty string. Looking at the
docs for gtk.Builder, I saw this:
"Objects must be given a name with the "id" attribute, which allows
the application to retrieve them from the builder with get_object().
An id is also necessary to use the object as property value in other
parts of the UI definition.
Note: Prior to GTK+ 2.20, gtk.Builder was setting the "name" property
of constructed widgets to the "id" attribute. In GTK+ 2.20 or newer,
you have to use gtk.Buildable.get_name() instead of
gtk.Widget.get_name() to obtain the "id", or set the "name" property
in your UI definition."
I can't tell what object gtk.Buildable is supposed to refer to. I
have a reference to a widget (in this case, a radio button, but I
think the problem is more general than that). How do I retrieve the
name I gave it in Glade?
Thx,
Skip Montanaro
More information about the pygtk
mailing list