I've figured out how to delete multiple selections. If anyone runs into the same problem, here's what I have learned: pygtk does not allow treemodel.remove(iter) in the selected_foreach(...) function, so I had to store all the iterators for the selected rows and then go back to delete them. The iterator parameter of the function called by selected_foreach is not the actual treestore row iterator, so I had to get it by using treemodel.get_iter(path). Only then was I abe to use treemodel.remove(iter) to remove the row. Here's my code:
# list that stores all the iterators of the selected rows selectList = [] # function to get iterator of selected row def GetSelectedIter(model,path,iter,rowList): selectIter = model.get_iter(path) rowList.append(selectIter) # get reference to each row selection = watchvar_treeview.get_selection() selection.selected_foreach(GetSelectedIter,selectList) # actual removal of rows for iter in selectList: watchvar_treestore.remove(iter) ~ Yang On Fri, 2003-09-26 at 15:35, Yang Zheng wrote: > Sorry for such a late response, but I just had a chance to come back to > the pygtk stuff. > > Thank you for your help. I tried using the following code and it > worked. However, it is meant only delete one row at a time right? > (since get_slected() does not work in SELECTION_MULTIPLE mode) If I > would like to delete multiple rows that are selected, do you have any > suggestions? Again, using selection.selected_foreach produced errors. > > > #Here is the function attached to the delete button: > > > > def RemoveWatchVariables(button): > > # delete each variable > > def DeleteVar(model,path,iter,data=None): > > model.remove(iter) > > # get selection and iterate through > > selection = watchvars_view.get_selection() > > selection.selected_foreach(DeleteVar) > > > On Tue, 2003-08-05 at 12:42, Grzegorz Adam Hankiewicz wrote: > > On 2003-08-05, Yang Zheng <[EMAIL PROTECTED]> wrote: > > > Can I not delete iterator like this? > > > > Hmmm... can't say what you do wrong, but here's my deletion code, > > maybe it helps you: > > > > selection = self.list_view.get_selection() > > model, iter, = selection.get_selected() > > if iter: > > path = model.get_path(iter) > > model.remove(iter) > > selection.select_path(path) > > if not selection.path_is_selected(path): > > row = path[0]-1 > > if row >= 0: > > selection.select_path((row,)) > > _______________________________________________ > pygtk mailing list [EMAIL PROTECTED] > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/