【发布时间】:2012-01-06 21:59:56
【问题描述】:
你好,我已经创建了 2 个框架,当我运行这个程序时,它会将每个框架显示为它们自己的应用程序(至少在 Windows 上)。有没有办法同时使用两个框架,但将它们放在一个应用程序中?
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()
这是我不想要的图像: http://i.stack.imgur.com/7gayc.png
那是我不想要的, 我希望两个框架都在一个应用程序中。
【问题讨论】:
-
您能否提供一个应用程序示例,该示例可以执行您/do/ 想要的操作?我猜测是 MDI,但我对这个猜测不太有信心。
-
(PS:不要做MDI,没人喜欢MDI。)