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!


thanks in advance
sandro
*:-)



-- 
Sandro Dentella  *:-)
http://www.reteisi.org             Soluzioni libere per le scuole
http://sqlkit.argolinux.org        SQLkit home page - PyGTK/python/sqlalchemy
"""
<interface>
  <requires lib="gtk+" version="2.16"/>
  <!-- interface-naming-policy project-wide -->
  <object class="GtkWindow" id="window1">
    <property name="visible">True</property>
    <child>
      <object class="GtkLabel" id="label1">
        <property name="visible">True</property>
        <property name="label" translatable="yes">label</property>
      </object>
    </child>
  </object>
</interface>
"""
import pygtk
pygtk.require('2.0')
import gtk

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
gtk.main()

"""<?xml version="1.0"?>
<glade-interface>
  <!-- interface-requires gtk+ 2.16 -->
  <!-- interface-naming-policy project-wide -->
  <widget class="GtkWindow" id="window1">
    <property name="visible">True</property>
    <child>
      <widget class="GtkLabel" id="label1">
        <property name="visible">True</property>
        <property name="label" translatable="yes">label</property>
      </widget>
    </child>
  </widget>
</glade-interface>
"""
import pygtk
pygtk.require('2.0')
import gtk.glade

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
gtk.main()

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to