def OnTreeTreeSelChanged(self, event):
if not self.IsBeingDeleted():
sometext = self.tree.GetItemText( event.GetItem() )
Thanks Robin! While we are at it - is it necessary to put these guarding
statements into other controls' events or is this something
treeCtrl-specific? (And why is treeCtrl doing this? It would've been
reasonable if it was deselecting all items, but strangely it is selecting
a valid item on its own)
def OnTreeTreeSelChanged(self, event):
if not self.IsBeingDeleted():
sometext = self.tree.GetItemText( event.GetItem() )
Thanks Robin! While we are at it - is it necessary to put these guarding
statements into other controls' events or is this something treeCtrl-specific?
Others may need it as well, it just depends on how the control works when it is destroyed.
(And why is treeCtrl doing this? It would've been
reasonable if it was deselecting all items, but strangely it is selecting
a valid item on its own)
As it is deleting the items if the item is selected then it selects a different item first before deleting it.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
This is the first time I've seen the need to guard against a Close or
Destroy. Seems like a design flaw to me. The selection change event
shouldn't be fired if the control is in the process of being deleted, so the
IsBeingDeleted check should be in the base wxWindows code, not something you
have to put in the user code event handler.
Is this a platform-specific problem due to how the native control works,
limited to wxTreeCtrl and its events?
Okay enough ranting, I am just very surprised by this.
ka
···
-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Robin Dunn
Sent: Wednesday, September 18, 2002 1:46 PM
To: wxpython-users@lists.wxwindows.org
Subject: Re: [wxPython] Re: Tree sends events during window destruction
- what to do? [wxPython pre6]
Ury Marshak wrote:
> Robin Dunn wrote:
>
> [...]
>
>>This will fix it for you:
>>
>> def OnTreeTreeSelChanged(self, event):
>> if not self.IsBeingDeleted():
>> sometext = self.tree.GetItemText( event.GetItem() )
>
>
> Thanks Robin! While we are at it - is it necessary to put these guarding
> statements into other controls' events or is this something
> treeCtrl-specific?
Others may need it as well, it just depends on how the control works
when it is destroyed.
> (And why is treeCtrl doing this? It would've been
> reasonable if it was deselecting all items, but strangely it is
selecting
> a valid item on its own)
As it is deleting the items if the item is selected then it selects a
different item first before deleting it.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!