-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/12/2010 13:59, Alessandro Dentella wrote:
> Hi,
>
> in the process of migrating from glade to Builder I wrote the 2 attached test
> files, where the main part is:
>
> >>> gld = gtk.glade.xml_new_from_buffer(__doc__,len(__doc__))
> >>> gld.get_widget('window1').connect('destroy', gtk.main_quit)
> >>> print "Lable.name", gld.get_widget('label1').name
> label1
>
> >>> bld = gtk.Builder()
> >>> bld.add_from_string(__doc__)
> >>> bld.get_object('window1').connect('destroy', gtk.main_quit)
> >>> print "Lable.name", bld.get_object('label1').name
> None
>
> Where clearlu 'name' attribute is empty for the object created w/ Builder
> and has the name I gave to the object in glade, for libglade.
>
> I don't know it a 'name' object should exists, but which is the canonical
> way to the get the name given in the glade interface?
>
> Not that clearly get_object('label1') works correctly!
There's a note in the GTK+ documentation [1] that states:
Prior to 2.20, GtkBuilder 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.
So, in your case the following works:
label = bld.get_object('label1')
print gtk.Buildable.get_name(label)
I have no idea why Glade saves the value of the "Name:" field from
the "General" tab as a gtkbuildable object id instead of a gtkwidget
name, but maybe it's related to the "Object names are unique (withing
the project||inside toplevels)" setting...
mvg,
Dieter
[1] http://library.gnome.org/devel/gtk/2.22/GtkBuilder.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk0Dey8ACgkQcdTd5T8YjL63JACgiKfqkRalKq27uW2N06v6T86t
+6EAnAv4V0CF2BzEkPq0wvdl/sJfgRS1
=Op6n
-----END PGP SIGNATURE-----
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/