The doc for wxTreeCtrl::GetSelection says, "Returns the selection, or an
invalid item if there is no selection."
I wonder whether it would be reasonable to make this function return None
when there is no current selected item.
For example, I would like to write code that gives the selected node if there
is one, the root node otherwise.
What factors should be considered in allowing the following
if not selected: selected = self.tree.GetRootItem ( )
for this purpose, rather than?
if not self.tree.IsSelected ( selected ):
selected = self.tree.GetRootItem ( )
The doc for wxTreeCtrl::GetSelection says, "Returns the selection, or an
invalid item if there is no selection."
I wonder whether it would be reasonable to make this function return None
when there is no current selected item.
Probably, but then it wouldn't match the docs.
For example, I would like to write code that gives the selected node if
there
is one, the root node otherwise.
What factors should be considered in allowing the following
if not selected: selected = self.tree.GetRootItem ( )
for this purpose, rather than?
if not self.tree.IsSelected ( selected ):
selected = self.tree.GetRootItem ( )
How about
if not selected.IsOk(): selected = self.tree.GetRootItem ( )
···
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!