I am learning wxpython and have a question.
When I create a treectrl within framework and call framework.show()
, the first item in the treectrl
is automatically selected (ie, EVT_TREE_SEL_CHANGED
event is fired). However, when I create a treectrl
in a panel, add the panel to a notebook and add the notebook to framework, the EVT_TREE_SEL_CHANGED
event is not fired when the framework.show()
is called. Instead, when I select an item in the treecontrol
later after the initial rendering, two EVT_TREE_SEL_CHANGED
are fired (one for the first item which is supposed to be fired during the initial rendering and the other one for the selected item).
panel.SetFocus()
in the bottom of framework.__init__()
fix this problem -- ie, fires EVT_TREE_SEL_CHANGED
to select the first item during the initial rendering. But, I wonder why this is happening. Does anybody know why EVT_TREE_SEL_CHANGED
is blocked in the initial rendering when the tree control is contained in the panel of notebook?
I don't know why exactly does this happen but this looks like a bug in wxWidgets. In practice, this means that it you shouldn't rely on this behaviour because it might (and in fact I'm pretty sure it does) behave differently under other platforms and also could change in future wxWidgets versions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.