Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions traitsui/wx/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ def skip_event ( self, event ):
def destroy_control ( self, control ):
""" Destroys a specified GUI toolkit control.
"""
_popEventHandlers(control)
control.Destroy()

#---------------------------------------------------------------------------
Expand All @@ -471,6 +472,8 @@ def destroy_children ( self, control ):
""" Destroys all of the child controls of a specified GUI toolkit
control.
"""
for child in control.GetChildren():
_popEventHandlers(child)
control.DestroyChildren()

#---------------------------------------------------------------------------
Expand Down Expand Up @@ -776,3 +779,13 @@ def _get_tab_hover_edge_bitmap ( self ):

return image.create_image().ConvertToBitmap()


#-------------------------------------------------------------------------------
def _popEventHandlers(ctrl):
""" Pop any event handlers that have been pushed on to a window and its
children.
"""
while ctrl is not ctrl.GetEventHandler():
ctrl.PopEventHandler(True)
for child in ctrl.GetChildren():
_popEventHandlers(child)