[pygtk] removing remaining rows in a liststore
Stuart Hughes
seh at zee2.com
Fri Nov 19 00:06:26 WST 2004
Hi everyone,
I'm reading data from a file into a gtk.ListStore. Sometimes the number
of rows in the file can reduce, so I want to be able to refresh the
valid rows, and delete the remaining invalid rows so they don't show up.
After refreshing the valid rows (the data runs out), I have an iter that
points at the first row that I need to remove. This is what I tried:
while iter:
self.lstore.remove(iter)
But this just got stuck in a tight loop as iter does not seem to
increment to the next row (possibly the pygtk2reference I have is old or
wrong).
So I tried:
while iter:
iter = self.lstore.remove(iter)
But remove seems just to return True, so I get an exception.
So I tried:
while iter:
self.lstore.remove(iter)
iter = self.lstore.iter_next(iter)
This mostly works, but sometimes I get:
GtkWarning: file gtkliststore.c: line 590 (gtk_list_store_iter_next):
assertion `GTK_LIST_STORE (tree_model)->stamp == iter->stamp' failed
iter = self.lstore.iter_next(iter)
Any ideas/suggestions warmly appreciated.
Regards, Stuart
More information about the pygtk
mailing list