Re: [pygtk] delete selection
Hello, I cannot get to the faq site. The operation always time out. Is anyone else having the same problem? thanks, ~ Yang On Fri, 2003-10-03 at 19:21, Christian Reis wrote: > On Wed, Oct 01, 2003 at 01:46:50PM -0700, Yang Zheng wrote: > > I've figured out how to delete multiple selections. If anyone runs into > > -> FAQ 13.22 > > http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.022.htp > > If you see anything wrong or worth improving, feel free to hack it :-) > > Take care, > -- > Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] delete selection
On Mon, Oct 06, 2003 at 10:25:24AM -0700, Yang Zheng wrote: > I cannot get to the faq site. The operation always time out. Is anyone > else having the same problem? Well, I moved the FAQ question too, and that won't help (our network connectivity seems okay to me at least, but we've got a thin straw out of the company) -- it's now FAQ 13.10 at http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.010.htp (Yes, I know this FAQ-moving business is lame; this is [hopefully] the final cleanup that resulted from breaking section 13 up; apologies and blissful forgetfulness to everybody affected) Take care, -- Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] delete selection
On Wed, Oct 01, 2003 at 01:46:50PM -0700, Yang Zheng wrote: > I've figured out how to delete multiple selections. If anyone runs into -> FAQ 13.22 http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.022.htp If you see anything wrong or worth improving, feel free to hack it :-) Take care, -- Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331 ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] delete selection
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/
Re: [pygtk] delete selection
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/
Re: [pygtk] delete selection
On Tue, Aug 05, 2003 at 09:42:56AM -0700, Yang Zheng wrote: > "(SimGuiClient.py:20194): Gtk-CRITICAL **: file gtktreeselection.c: line > 491 (gtk_tree_selection_selected_foreach): assertion `has_next' failed. > There is a disparity between the internal view of the GtkTreeView, > and the GtkTreeModel. This generally means that the model has changed > without letting the view know. Any display from now on is likely to > be incorrect." > > #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) The way I see it, selection probably doesn't expect you to delete items from it in a foreach loop (maybe I'm wrong, but since nobody else has answered on that point..). It's probably safer to get the model and iter from selection and work using that. If someone knows, I'll update the FAQ with the rationale. Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] delete selection
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,)) -- Please don't send me private copies of your public answers. Thanks. ___ 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] delete selection
Hello, I am trying to implement a GUI showing a list in TreeView/TreeStore. I would like to be able to select a range of values from the list and press a button to delete it. However, I keep getting the following error when trying to delete: "(SimGuiClient.py:20194): Gtk-CRITICAL **: file gtktreeselection.c: line 491 (gtk_tree_selection_selected_foreach): assertion `has_next' failed. There is a disparity between the internal view of the GtkTreeView, and the GtkTreeModel. This generally means that the model has changed without letting the view know. Any display from now on is likely to be incorrect." #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) remove_watchvar_button = xml.get_widget('remove_watchvar_button') remove_watchvar_button.connect('clicked',RemoveWatchVariables) Can I not delete iterator like this? Thank you! ~ yz. ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/