Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
Prevent toplevel wx windows from being destroyed on close.
Browse files Browse the repository at this point in the history
Update the Window class to toggle visibility to False when closed.
  • Loading branch information
sccolbert committed Jan 23, 2013
1 parent c090c0f commit 8e298e7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions enaml/widgets/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def on_action_closed(self, content):
""" Handle the 'closed' action from the client widget.
"""
self.set_guarded(visible=False)
self.closed()
if self.destroy_on_close:
self.destroy()
Expand Down
10 changes: 10 additions & 0 deletions enaml/wx/wx_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, *args, **kwargs):
self._tool_bars = None
self._batch = False
self.Bind(wx.EVT_MENU, self.OnMenu)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.Bind(aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose)
self.Bind(aui.EVT_AUI_PANE_FLOATED, self.OnPaneFloated)
self.Bind(aui.EVT_AUI_PANE_DOCKED, self.OnPaneDocked)
Expand Down Expand Up @@ -160,6 +161,15 @@ def OnMenu(self, event):
action.SetChecked(event.Checked())
action.Trigger()

def OnClose(self, event):
""" The event handler for the EVT_CLOSE event.
This event handler prevents the frame from being destroyed on
close. Instead it just sets the visibility to False.
"""
self.Hide()

#--------------------------------------------------------------------------
# Public API
#--------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions enaml/wx/wx_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, *args, **kwargs):
self._central_widget = None
self.SetSizer(wxSingleWidgetSizer())
self.Bind(wx.EVT_MENU, self.OnMenu)
self.Bind(wx.EVT_CLOSE, self.OnClose)

#--------------------------------------------------------------------------
# Event Handlers
Expand All @@ -49,6 +50,15 @@ def OnMenu(self, event):
action.SetChecked(event.Checked())
action.Trigger()

def OnClose(self, event):
""" The event handler for the EVT_CLOSE event.
This event handler prevents the frame from being destroyed on
close. Instead it just sets the visibility to False.
"""
self.Hide()

#--------------------------------------------------------------------------
# Public API
#--------------------------------------------------------------------------
Expand Down

0 comments on commit 8e298e7

Please sign in to comment.