"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/

Reply via email to