Re: TreeFilterModel and sorting





stian nixia no wrote:
I've just run into this problem (using pygtk).

I'd like to have a liststore that is both sortable and filterable.

In fact, I had such a beast, but I was using my own nasty hacks to
implement the filtering.  I've had on my to-do list to switch to the
TreeModelFilter + I've just tried that -- unfortunately it seems I can
either have filtering or sorting, but not both.

Am I missing some trick?
    

You can stack models

GtkListStore
GtkFilterStore
GtkSortStore

And use the Store are the model in the GtkTreeview

Stian
  
Many thanks for this -- I'd just discovered the same as your e-mail came in.

My (pygtk) code now looks like this and is working pretty well.

������� # Get a ListStore
������� self.store = gtk.ListStore(*self.col_types)������
�������
������� # Add filtering
������� filtered_model = self.store.filter_new()
������� filtered_model.set_visible_column(self.store.get_n_columns()-1self)

������� # And now add sorting
������� self.filtered_model = gtk.TreeModelSort(filtered_model)

������� self.view.set_model(self.filtered_model)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]