I'm using Glade to design my UI, which introduced some difficulty in figuring out how to populate my ComboBox (of which there are 2 versions in PyGTK). The PyGTK Tutorial was helpful, and the PyGTK IRC Channel took me the last mile.
The short of it is, a ComboBox works like a TreeView:
# create a store
weapon_store=gtk.ListStore(gobject.TYPE_STRING)
# populate the store
for w in weapon_names:
row=weapon_store.insert_after(None, None)
weapon_store.set_value(row, 0, w)
# get the Glade widget
left_hand_weapon_cbo=self.widgets.get_widget('leftHandWeapon')
left_hand_weapon_cbo.set_model(weapon_store)
# the business bit
cell=gtk.CellRendererText()
left_hand_weapon_cbo.pack_start(cell)
left_hand_weapon_cbo.add_attribute(cell, 'text', 0)
left_hand_weapon_cbo.set_wrap_width(3)
It would be nice if the Glade/PyGTK infrastructure would do more of the work of setting up the widgets with sensible defaults.
Showing posts with label Glade. Show all posts
Showing posts with label Glade. Show all posts
Saturday, February 3, 2007
Monday, January 22, 2007
First Thoughts
Glade is quite nice apart from the GIMP-style multi window UI. It's incredibly frustrating to have a web page with instructions (or another app with a mockup) underneath Glade, then click that app and then have to raise each of the four Glade windows separately. Makes absolutely no sense. A friend of mine suggests that's what multiple desktops are for, but this is a clumsy workaround.
Found a good tutorial on Glade + Python. It's all text, and somewhat outdated, but was the most helpful of the stuff I read.
Found a good tutorial on Glade + Python. It's all text, and somewhat outdated, but was the most helpful of the stuff I read.
Subscribe to:
Posts (Atom)