Re: TreeFilterModel and sorting

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

 





stian@xxxxxxxx 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)


_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux