【问题标题】:selecting an item in a combobox pygtk glade3在组合框中选择一个项目 pygtk glade3
【发布时间】:2011-09-10 12:22:38
【问题描述】:

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

interface.py:94: Warning: unable to set property `text' of type `gchararray' from 
value of type `glong'
gtk.main()

我的组合框代码在这里

#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)

任何帮助将不胜感激:)。

【问题讨论】:

  • 你能解决这个问题吗?

标签: python combobox gtk pygtk glade


【解决方案1】:

我有这个工作(但我不使用林间空地):

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 类型不正确。 请尝试:

  self.cbmoRepresentation = builder.get_object("cmbo_representation")
  print type(self.cbmoRepresentation)

检查 cbmoRepresentation 的类型。

【讨论】:

  • 是输出。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-28
  • 2012-05-16
  • 1970-01-01
  • 1970-01-01
  • 2013-12-04
  • 2019-03-29
相关资源
最近更新 更多