使用 wx.wizard 配置菜单
Configuring a menu with wx.wizard
是否可以使用 wx.wizard 配置菜单栏? class 似乎没有 SetMenuBar 方法。以下失败并出现错误:AttributeError: 'MyWizard' object has no attribute 'SetMenuBar'
。
import wx
import wx.wizard
class MyWizard(wx.wizard.Wizard):
def __init__(self):
wx.wizard.Wizard.__init__(self, None, id=wx.ID_ANY, title="Test", pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE)
self.m_pages = []
self.m_wizPage = wx.wizard.WizardPageSimple(self)
self.add_page(self.m_wizPage)
# Menu
menub = wx.MenuBar()
# File Menu
filem = wx.Menu()
filem.Append(wx.ID_OPEN, "Open\tCtrl+O")
menub.Append(filem, "&File")
self.SetMenuBar(menub)
def add_page(self, page):
if self.m_pages:
previous_page = self.m_pages[-1]
page.SetPrev(previous_page)
previous_page.SetNext(page)
self.m_pages.append(page)
if __name__ == '__main__':
app = wx.App(False)
wiz = MyWizard()
wiz.RunWizard(wiz.m_pages[0])
wiz.Destroy()
没有。 Wizard
class 派生自 wx.Dialog
,对话框没有菜单。如果你真的想要一个那么你可以尝试使用 wx.lib.agw.flatmenu
.
中的通用实现
是否可以使用 wx.wizard 配置菜单栏? class 似乎没有 SetMenuBar 方法。以下失败并出现错误:AttributeError: 'MyWizard' object has no attribute 'SetMenuBar'
。
import wx
import wx.wizard
class MyWizard(wx.wizard.Wizard):
def __init__(self):
wx.wizard.Wizard.__init__(self, None, id=wx.ID_ANY, title="Test", pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE)
self.m_pages = []
self.m_wizPage = wx.wizard.WizardPageSimple(self)
self.add_page(self.m_wizPage)
# Menu
menub = wx.MenuBar()
# File Menu
filem = wx.Menu()
filem.Append(wx.ID_OPEN, "Open\tCtrl+O")
menub.Append(filem, "&File")
self.SetMenuBar(menub)
def add_page(self, page):
if self.m_pages:
previous_page = self.m_pages[-1]
page.SetPrev(previous_page)
previous_page.SetNext(page)
self.m_pages.append(page)
if __name__ == '__main__':
app = wx.App(False)
wiz = MyWizard()
wiz.RunWizard(wiz.m_pages[0])
wiz.Destroy()
没有。 Wizard
class 派生自 wx.Dialog
,对话框没有菜单。如果你真的想要一个那么你可以尝试使用 wx.lib.agw.flatmenu
.