在打开另一个框架后,如何访问wxPython中的大型机?

在打开另一个框架后,如何访问wxPython中的大型机?,wxpython,Wxpython,实际上,我想做的是访问我创建的所有帧。这里我创建了3个帧-“大型机”、“第一帧”、“第二帧”。因此,我想随时打开、关闭或最小化任何帧。是否可以关闭“大型机”没有关闭其他帧??我已经制作了一个程序。但是在这里,我无法在打开其他帧而没有关闭它们之后访问主机 这是我的密码- import wx class MainFrame(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,"M

实际上,我想做的是访问我创建的所有帧。这里我创建了3个帧-“大型机”、“第一帧”、“第二帧”。因此,我想随时打开、关闭或最小化任何帧。是否可以关闭“大型机”没有关闭其他帧??我已经制作了一个程序。但是在这里,我无法在打开其他帧而没有关闭它们之后访问主机

这是我的密码-

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()

您无法访问主窗口,因为您已将其他窗口设置为模态,这是模态的全部要点,以停止所有其他操作,并等待模态框架关闭,然后再返回到上一个框架

若要在父帧关闭时停止子帧关闭,需要使其成为独立帧。 要执行此操作,而不是将self作为父对象,请将None作为父对象传递