0
我想要做的實際上是我想要訪問所有我創建的框架。在這裏我創建了3個框架 - 「MainFrame」,「FirstFrame」,「SecondFrame」。因此,我想打開,關閉或者最小化任何我想要的幀。是否可以關閉「MainFrame」而不關閉其他幀?我已經創建了一個程序。但是,在打開其他幀而不關閉它們之後,我無法訪問MainFrame。如何在打開另一個框架後訪問wxPython中的MainFrame?
這裏是我的代碼 -
import wx
class MainFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,"Main WIndow",size=(600,400))
panel=wx.Panel(self)
self.button1=wx.Button(panel,label='First Window',pos=(80,30),size=(130,50))
self.button2=wx.Button(panel,label='Second Window',pos=(80,100),size=(130,50))
self.Bind(wx.EVT_BUTTON,self.evt1,self.button1)
self.Bind(wx.EVT_BUTTON,self.evt2,self.button2)
def evt1(self,parent):
frame=FirstFrame(self,-1)
frame.Show(True)
frame.MakeModal(True)
def evt2(self,parent):
frame=SecondFrame(self,-1)
frame.Show(True)
frame.MakeModal(True)
class FirstFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,"First Window",size=(600,400))
self.Bind(wx.EVT_CLOSE, self.on_close)
def on_close(self, evt):
self.MakeModal(False)
evt.Skip()
class SecondFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,"Second Window",size=(600,400))
self.Bind(wx.EVT_CLOSE, self.on_close1)
def on_close1(self, evt):
self.MakeModal(False)
evt.Skip()
if __name__=='__main__':
app=wx.PySimpleApp()
frame=MainFrame(None,-1)
frame.Show()
app.MainLoop()