Doug Quale wrote:
The docs are wrong in that the return value in PyGTK 2.4 and above is a boolean indicating whether iter is valid since 2.3.92. My mistake and thanks for pointing it out. However the docs are right that remove(iter) will advance the iter (i.e. point at the next row if any) unless there is no next row in which case iter is invalid.Chris Lambacher <[EMAIL PROTECTED]> writes:
if iter does not override the __nonzero__ method from object, the while loop will always evaluate iter as true. The documenation says that listtstore.remove sets iter to the next valid row so the original unless it is the last row in which case the iter is invalidated. so the while loop needs to check if iter is valid using liststore.iter_is_valid:
while self.lstore.iter_is_valid(iter): self.lstore.remove(iter)
if remove invalidates iter rather than setting it to the next line,
the documentation needs to be updated.
I think the docs are wrong and remove(iter) won't advance the iter.
To answer Stuart's question about removing the rest of the rows in a ListStore:
If using PyGTK 2.3.92 and above you could use:
while self.lstore.remove(iter): pass
If using PyGTK 2.2 and above:
while self.lstore.iter_is_valid(iter): self.lstore.remove(iter)
And if using PyGTK 2.0 and above:
start = self.lstore.get_path(iter)[0] for row in range(start, len(self.lstore)): self.lstore.remove(iter)
John
_______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
