- 论坛徽章:
- 0
|
小弟新学 wxpython,有很多东西不熟悉。非常希望得到各位的帮助,非常感谢。
以下是一段示例代码,运行代码后,发现菜单栏上多了一个“Window”菜单,而代码中并没有写入这个菜单。
百思不得其解,特地贴出来,求各位达人赐教:
- import wx
- import wx.aui
- class ParentFrame(wx.aui.AuiMDIParentFrame):
- def __init__(self, parent):
- wx.aui.AuiMDIParentFrame.__init__(self, parent, -1,
- title="AuiMDIParentFrame",
- size=(640,480),
- style=wx.DEFAULT_FRAME_STYLE)
- self.count = 0
- mb = self.MakeMenuBar()
- self.SetMenuBar(mb)
- self.CreateStatusBar()
- def MakeMenuBar(self):
- mb = wx.MenuBar()
- menu = wx.Menu()
- item = menu.Append(-1, "New child window\tCtrl-N")
- self.Bind(wx.EVT_MENU, self.OnNewChild, item)
- item = menu.Append(-1, "Close parent")
- self.Bind(wx.EVT_MENU, self.OnDoClose, item)
- mb.Append(menu, "&File")
- return mb
- def OnNewChild(self, evt):
- self.count += 1
- child = ChildFrame(self, self.count)
- child.Show()
- def OnDoClose(self, evt):
- self.Close()
- class ChildFrame(wx.aui.AuiMDIChildFrame):
- def __init__(self, parent, count):
- wx.aui.AuiMDIChildFrame.__init__(self, parent, -1,
- title="Child: %d" % count)
- p = wx.Panel(self)
- wx.StaticText(p, -1, "This is child %d" % count, (10,10))
- p.SetBackgroundColour('light blue')
- sizer = wx.BoxSizer()
- sizer.Add(p, 1, wx.EXPAND)
- self.SetSizer(sizer)
- wx.CallAfter(self.Layout)
- if __name__ == '__main__':
- app = wx.PySimpleApp(False)
- frame = ParentFrame(None)
- frame.Show()
- app.SetTopWindow(frame)
- app.MainLoop()
复制代码 |
|