Выбор предмета в выпадающем списке pygtk glade3 - PullRequest
1 голос
/ 10 сентября 2011

Использование 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)

Любая помощь будет очень признательна :).

1 Ответ

0 голосов
/ 10 сентября 2011

У меня есть это, что работает (но я не использую glade):

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.

...