I have created a wx.Frame(lets call it mainFrame). This frame contains a button on it, when the button is clicked, a new frame(lets call it childFrame) is created.
I want to know that how to disable the mainFrame when childFrame is created and enable the mainFrame again when childFrame distroyed/closed?
Regars,
May be you want something like this:
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.NewId(), "Main")
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.button = wx.Button(self, wx.NewId(), "Open a child")
self.sizer.Add(self.button, proportion=0, border=2, flag=wx.ALL)
self.SetSizer(self.sizer)
self.button.Bind(wx.EVT_BUTTON, self.on_button)
self.Layout()
def on_button(self, evt):
frame = ChildFrame(self)
frame.Show(True)
frame.MakeModal(True)
class ChildFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, wx.NewId(), "Child")
self.Bind(wx.EVT_CLOSE, self.on_close)
def on_close(self, evt):
self.MakeModal(False)
evt.Skip()
class MyApp(wx.App):
def OnInit(self):
frame = MainFrame()
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
May be you do not need another frame but a modal dialog e.g.
import wx
app = wx.PySimpleApp()
mainFrame = wx.Frame(None, title="Click inside me")
def onMouseUp(event):
dlg = wx.Dialog(mainFrame,title="I am modal, close me first to get to main frame")
dlg.ShowModal()
mainFrame.Bind(wx.EVT_LEFT_UP, onMouseUp)
mainFrame.Show()
app.SetTopWindow(mainFrame)
app.MainLoop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With