[pygtk] gtk.CellRendererCombo usage question
Kestas -
kestas at pixel.lt
Thu May 8 16:08:09 WST 2008
Hello
I using gtk.TreeView. I added in one of many colums gtk.CellRendererCombo.
But i have problem ..
Code works good, but not as i want ..
I rendering gtkCellRendererCombo like this .. It's OK
def make_cell_render(self):
liststore =3D gtk.ListStore(gobject.TYPE_STRING)
tiekejai =3D self.db.get_names_from_database() # i am getting from
database(mysql) companies names
for t in tiekejai:
liststore.append((t))
self.cell =3D gtk.CellRendererCombo()
self.cell.set_property("text-column", 0)
self.cell.set_property('editable', True)
self.cell.set_property('model', liststore)
self.cell.connect('editing-started', self.text_editing_started)
self.cell.connect('edited', self.cell_edited_cb)
return self.cell
I created callback self.cell_edited_cb
Because i want to change combo box value ..
my callback:
def cell_edited_cb(self, cell, path, new_text):
model =3D self.treeview.get_model()
iter =3D model.get_iter_from_string(path)
k =3D self.db.tiekejo_id_by_name(new_text)
model.set(iter, 3, new_text) # 3 it's number of column in treeview
(with CellRenederCombo)
This code changes combo box text .. And there's problem .. I need to track
not just companies names, but companies ID's .. i have company table .. with
name and and ID's and other information ...
I need somehow store additional value (companie id, not just company name)
.. because i don't want to perform search ( by using just company name
value) .. Because there's can be company by the same name, but the address
different ..
Actually i think:
liststore =3D gtk.ListStore(gobject.TYPE_STRING)
i need to change to liststore =3D gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_STRING) .. and somehow extract 2nd value in callback code ..
But i don't know how ..
Any help will be appropriate ..
kestaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20080508/7b937cf6/at=
tachment.htm
More information about the pygtk
mailing list