Hari's Corner
Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and thenPython Gtk HOWTO: deleting multiple selected items from a gtk.TreeView
Filed under:
Tutorials and HOWTOs by
Hari
Posted on Tue, May 25, 2010 at 08:33 IST (last updated: Tue, May 25, 2010 @ 08:49 IST)
In this series | < Previous |
get_object ()
method of the GtkBuilder object to get the widgets.
As you can see, it involves the following steps:def remove_selected_items (self): # get the file treeview and liststore file_view = self.ui.get_object ("tree_files") file_list = self.ui.get_object ("filelist") # get the selected rows as paths sel_model, sel_rows = file_view.get_selection ().get_selected_rows () # store the treeiters from paths iters = [] for row in sel_rows: iters.append ( file_list.get_iter (row) ) # remove the rows (treeiters) for i in iters: if i is not None: file_list.remove (i)
- Get the TreeSelection object associated with the
TreeView
and callget_selected_rows ()
to get the row model and selected paths. - Convert each of the selected paths into
TreeIter
s. - Now call the method
remove ()
method on each of the selected items in theListStore
orTreeModel
object.
In this series
- Python Gtk HOWTO: deleting multiple selected items from a gtk.TreeView
- Python Gtk HOWTO: cell rendering a Treeview created in Glade
Comments closed
The blog owner has closed further commenting on this entry.
2 comment(s)
It works perfectly fine
Thanks a lot for sharing that !
Clearly treemodel are quite a pain in the a** to manipulate.
Comment by TeT (visitor) on Fri, Sep 17, 2010 @ 20:13 IST #
Comment by Hari (blog owner) on Fri, Sep 17, 2010 @ 20:44 IST #