I'm having trouble updating a treectrl after it's been displayed for the
first time (but adding stuff in _init_ works fine).
I've attached a simple example, how would I add an item E.g. bananas
outside of _init_
Exactly the same as within __init__, you just need to have a reference to the tree_ctrl and the tree item that you want to use as the parent of the new item. Saving those references in self is the typical way to do that.
I wasn't sure where you tried using self in this latest example, but,
if so, it wasn't in the way Robin meant. Two things are wrong with
this code that I see:
1) You don't use self.root and self.tree_ctrl (which will therefore be
"global" to the whole class and therefore accessible from within any
function), but instead use root and tree_ctrl. Those are only
accessible names within the function they are defined in (in this
case, the __init__ function).
2) You define the test() function, but you never actually call it.
Both of these are corrected in the edited version of your example, attached.