I have a TreeCtrl object where the tree items are appended only when a
node is expanded. So what I did was to create a function OnItemExpand
that adds tree items and make this as the handler for
EVT_TREE_ITEM_EXPANDED.
At the initial loading, the root is added and expanded by calling
'Expand'. The tree items under the root are added by calling another
function. My code goes something like this:
class MyTreeCtrl(wxTreeCtrl):
def __init__(self,....):
:
tID = wxNewId()
wxTreeCtrl.__init__(self,parent,......)
I want to simplify __init__ part by generating a TREE_ITEM_EXPANDED
event instead. So what I did was I get rid of the call to the
self.Expand and self.AddItems functions and added the following calls
instead:
(1) The event is sent but the tree is not expanding.
(2) I am getting an error "assert "wxFalse" failed: invalid tree item"
during the call to GetItemText(item) under OnItemExpanded.
(3) How can I specify which node I want to expand using this approach
(i.e. if this is possible at all)?
I have a TreeCtrl object where the tree items are appended only when a
node is expanded. So what I did was to create a function OnItemExpand
that adds tree items and make this as the handler for
EVT_TREE_ITEM_EXPANDED.
At the initial loading, the root is added and expanded by calling
'Expand'. The tree items under the root are added by calling another
function. My code goes something like this:
class MyTreeCtrl(wxTreeCtrl):
def __init__(self,....): : tID = wxNewId()
wxTreeCtrl.__init__(self,parent,......)
I want to simplify __init__ part by generating a TREE_ITEM_EXPANDED
event instead. So what I did was I get rid of the call to the
self.Expand and self.AddItems functions and added the following calls
instead:
(1) The event is sent but the tree is not expanding.
The sending of the event does not cause the item to be expanded, rather normally the event is sent because the item was expanded. So you'll still need to cause the item to be expanded.
(2) I am getting an error "assert "wxFalse" failed: invalid tree item"
during the call to GetItemText(item) under OnItemExpanded.
Because the item in the event object is not valid.
(3) How can I specify which node I want to expand using this approach
(i.e. if this is possible at all)?
You can't. There are no public methods in wxTreeEvent for setting the tree item and other members.
Hope you can help me on this.
You'll probably want to stick with your original approach.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!