Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1361428
  • 博文数量: 343
  • 博客积分: 13098
  • 博客等级: 上将
  • 技术积分: 2862
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-06 00:35
文章存档

2012年(131)

2011年(31)

2010年(53)

2009年(23)

2008年(62)

2007年(2)

2006年(36)

2005年(5)

分类: Python/Ruby

2011-02-17 01:34:06

使用glade创建的combox, 其对应的liststore不能绑定到python的string类型, 所以需要在程序中手工写代码来创建combox对应的liststore. pygtk faq有个很好的例子,细节可以参考:

For glade users, you can create a simple model for your ComboBox* using

  store = gtk.ListStore(gobject.TYPE_STRING)
  store.append (["testing1"])
  store.append (["testing2"])
  store.append (["testing3"])
  store.append (["testing4"])
For a ComboBoxEntry, it's then a matter of assigning the model to the combo and specifying the text column:

  combo = tree.get_widget("comboboxentry1")
  combo.set_model(store)
  combo.set_text_column(0)
For a ComboBox, pack a renderer into it, specifying the text cell:

  combo = tree.get_widget("combobox1")
  combo.set_model(store)
  cell = gtk.CellRendererText()
  combo.pack_start(cell, True)
  combo.add_attribute(cell, 'text',0)

阅读(1735) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~