Docs (was Re: [pygtk] How to remove a row from a GTK.ListStore?)
> Do note that both the official reference and the FAQ have evolved > quite a lot over the last year, and I wouldn't call our current > documentation"poor", even if it isn't *that* easy to find. We're > trying to address this aspect of the problem, by the way. > As a newcomer to python I was pleasantly surprised by how good the docs were. I've had a steep learning curve and so far, a combination of the tutotial, the reference and the FAQ have answered all the questions I've had. And as for finding them - a google search for "pygtk" brings up the tutorial (at moeraki.com) and the FAQ on the first page. A link from the tutorial to the reference would be nice though. Regards, Chris ___ 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] How to remove a row from a GTK.ListStore?
On Sat, Nov 01, 2003 at 12:52:56PM -0500, Hans Deragon wrote: > Newbie here. I tried to figure out how to remove a row from a > GTK.ListStore on the web (documentation and mailing list archives), but I > could not figure it out. The documentation is pretty poor. I wonder if you mean http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.008.htp -- ? If so, it would be nice to know what was hard to understand in the example. Note there's also http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.025.htp Do note that both the official reference and the FAQ have evolved quite a lot over the last year, and I wouldn't call our current documentation "poor", even if it isn't *that* easy to find. We're trying to address this aspect of the problem, by the way. Take care, -- Christian Robottom 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] How to remove a row from a GTK.ListStore?
"David M. Cook" <[EMAIL PROTECTED]> writes: > TreeView contains a selection object that manages user selections. You need > to get the selection object, then query it for the selected path with the > get_selected() method. For single selection mode: > > selection = treeview.get_selection() > result = selection.get_selected() > if result: #result could be None >model, iter = result > model.remove(iter) This isn't quite right -- get_selected() returns a tuple, never None. If there's no selection only the treeiter is None. The model will always be returned. Try this instead: selection = treeview.get_selection() model, treeiter = selection.get_selected() # If there's no selection, treeiter will be None if treeiter is not None: model.remove(treeiter) As David warns, the 'selection-changed' signal will be emitted sometimes when there's no current selection. You should always test before you try to use the selection. ___ 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] How to remove a row from a GTK.ListStore?
On Sat, Nov 01, 2003 at 12:52:56PM -0500, Hans Deragon wrote: > Newbie here. I tried to figure out how to remove a row from a > GTK.ListStore on the web (documentation and mailing list archives), but I > could not figure it out. The documentation is pretty poor. > > What I want to figure out is how can I get the iter required by > GTK.ListStore.remove()? I have a GTK.TreeView with at GTK.ListStore as a > Model. I want to remove the row that has been selected by the user. How > do I proceed? How do I obtain the iter that points to the currently > selected item? It must be easy, but I cannot find the function that would > return the iter. TreeView contains a selection object that manages user selections. You need to get the selection object, then query it for the selected path with the get_selected() method. For single selection mode: selection = treeview.get_selection() result = selection.get_selected() if result: #result could be None model, iter = result model.remove(iter) For multiple selection mode you need to use a little hack to get the selected paths until get_selected_rows() is implemented (2.2 API): rows = [] selection.selected_foreach(lambda model, path, iter: rows.append(path)) rows will then be a list of selected paths, and you can use model.get_iter(path) to get the iters. Note that this "hack" will work with either selection mode, so I use it everywhere instead of get_selected(). Dave Cook ___ 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] How to remove a row from a GTK.ListStore?
Greetings. Newbie here. I tried to figure out how to remove a row from a GTK.ListStore on the web (documentation and mailing list archives), but I could not figure it out. The documentation is pretty poor. What I want to figure out is how can I get the iter required by GTK.ListStore.remove()? I have a GTK.TreeView with at GTK.ListStore as a Model. I want to remove the row that has been selected by the user. How do I proceed? How do I obtain the iter that points to the currently selected item? It must be easy, but I cannot find the function that would return the iter. On a different note, if I want to remove a row containing the String "blahblah" from a GTK.ListStore, how would I proceed? My main problem is that I cannot figure out how to create an iter. It is being required many places, but I cannot put my hand on how to create one which would point to the data I would desire. Sincerely, Hans Deragon -- Deragon Informatique inc. Open source: http://www.deragon.bizhttp://swtmvcwrapper.sourceforge.net mailto://[EMAIL PROTECTED] http://autopoweroff.sourceforge.net ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/