我需要通过单击按钮在 wxpython 中创建一个额外的新窗口(它与主窗口在物理上是分开的)。我想在不关闭最后一个窗口的情况下执行此操作。
这是我到目前为止所拥有的:
class Prototype(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, None, size=(1240,705))
self.UI()
self.Centre()
self.Show()
def UI(self):
self.panel1 = wx.Panel(self, -1)
self.sizer = wx.BoxSizer()
self.sizer.Add(self.panel1, 1, flag=wx.EXPAND)
b = wx.Button(self.panel1, label='second window', size=(180,100), pos=(650,25))
b.Bind(wx.EVT_BUTTON, self.OnB)
self.panel2 = wx.Panel(self, -1)
self.sizer.Add(self.panel2,1,flag=wx.EXPAND)
self.panel2.Hide()
self.panel2.SetSizer(self.vbox)
self.SetSizer(self.sizer)
def OnB(self, event):
self.panel2.Show()
self.sizer.Layout()
app = wx.App()
Prototype(None, title='')
app.MainLoop()