[pygtk] treeview - liststore sort problem
Peter Morgan
pm at daffodil.uk.com
Sat Sep 16 20:08:31 WST 2006
Hi all,
Relitavely new to pygtk, porting old VB apps to new platform using
glade ;-) and its working and fun.. No more Win98 .. Ubuntu is IT
Here are my problems:
I have a ListStore which loads a lookup table from a database and is a
self.ListStoreObject on my "main" class - this is a list of Categories
for my app with id/value pair eg 1 = 'Foo', 2 = 'Bar'
Its set as the model for a ComboBox which is on the "main" window and
acts as a "filter" dropdown in the application.
I also have a popup window (not dialog) to edit the list which is a
TreeView "bound" to the ListStore; the ListStore object is "handed" over
in the constructor.
Problem is that if I click on a column to "sort" in the the popup
editor's treeview, the combobox on the main form is also "resorted". I
was under the assumption that the "sort" was done in the treeview widget
and NOT the liststore ? How do I get around this ?
The Combobox
## Set up the Categores dropdown
ev_types = self.wTree.get_widget('event-types-combo')
ev_types.set_model(self.StatusEvents)
cell = gtk.CellRendererText()
ev_types.pack_start(cell, True)
#ev_types.add_attribute(cell, 'text', 1)
ev_types.set_text_column(1)
The Treeview
## Initialised the "tree" widget in the middle
def init_tree(self):
#self.tree.connect("row-activated", self.category_row_activated)
self.tree.get_selection().connect('changed',
self.tree_row_activated)
# add the ID Column
column = gtk.TreeViewColumn('#',gtk.CellRendererText(),text=0 )
column.set_resizable(True)
column.set_sort_column_id(0)
self.tree.append_column(column)
# add the Category name column
renderer = gtk.CellRendererText()
renderer.connect('edited', self.tree_cell_edited_callback)
renderer.connect('editing-started', self.tree_cell_start_edit)
renderer.set_property('editable', True)
column = gtk.TreeViewColumn(self.item, renderer, text=1)
column.set_resizable(True)
column.set_sort_column_id(1)
self.tree.append_column(column)
# add the count Column
column = gtk.TreeViewColumn('Count',gtk.CellRendererText(),text=2 )
column.set_resizable(True)
column.set_sort_column_id(2)
self.tree.append_column(column)
# Create and attach the "store" model
#self.store = gtk.ListStore(int, str)
self.tree.set_model(self.main.CategoriesStore)
self.tree.set_rules_hint(True)
Also:
How do I make the "ComboBox" widget accept text.. as in Visual Basic..
SO users can select something from the droplist or tap in their own ? Do
I need to create and EntryBox and overlay ?
tia
Pete ;-)
More information about the pygtk
mailing list