首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在combobox pygtk glade3中选择项目

在combobox pygtk glade3中选择项目
EN

Stack Overflow用户
提问于 2011-09-10 20:22:39
回答 1查看 897关注 0票数 1

使用pygtk 2.24和glade 3时,我在使用组合框时遇到了问题。当我单击其中的一个项目时,我得到以下错误信息

代码语言:javascript
复制
interface.py:94: Warning: unable to set property `text' of type `gchararray' from 
value of type `glong'
gtk.main()

我的combobox代码在这里

代码语言:javascript
复制
#get the combo box out of the builder and add items to it
self.cbmoRepresentation = builder.get_object("cmbo_representation")
self.iface_list_store = gtk.ListStore(gobject.TYPE_STRING)
self.iface_list_store.append(["Row-Column"])
self.iface_list_store.append(["Row-Number"])
self.iface_list_store.append(["Number-Column"])
self.cbmoRepresentation.set_model(self.iface_list_store)
cell = gtk.CellRendererText()
self.cbmoRepresentation.pack_start(cell, True)
self.cbmoRepresentation.add_attribute(cell, "text", 0)
self.cbmoRepresentation.set_active(-1)

任何帮助都会非常感谢:)。

EN

回答 1

Stack Overflow用户

发布于 2011-09-10 20:37:04

我有这样的工作(但我不使用glade):

代码语言:javascript
复制
liststore = gtk.ListStore(gobject.TYPE_STRING)
combobox = gtk.ComboBox(liststore)
cell = gtk.CellRendererText()
combobox.pack_start(cell, True)
combobox.add_attribute(cell, 'text', 0)

所以我怀疑你的self.cbmoRepresentation类型不正确。请尝试:

代码语言:javascript
复制
  self.cbmoRepresentation = builder.get_object("cmbo_representation")
  print type(self.cbmoRepresentation)

检查cbmoRepresentation的类型。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7371645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档