def _build_menu(self):
"""Build the application menu."""
menubar = wx.MenuBar()
file_menu = wx.Menu()
help_menu = wx.Menu()
self.Bind(wx.EVT_MENU, self._directory_chooser, file_menu.Append(wx.ID_OPEN, 'Open directory...'))
self.Bind(wx.EVT_MENU, self._open_settings, file_menu.Append(wx.ID_PROPERTIES, 'Settings...'))
file_menu.AppendSeparator()
self.Bind(wx.EVT_MENU, lambda evt: self.Close(), file_menu.Append(wx.ID_EXIT))
self.Bind(wx.EVT_MENU, self._open_about, help_menu.Append(wx.ID_ABOUT))
self.Bind(wx.EVT_MENU, lambda evt: wx.LaunchDefaultBrowser("http://irida-miseq-uploader.readthedocs.io/en/latest/"), help_menu.Append(wx.ID_HELP))
menubar.Append(file_menu, '&File')
menubar.Append(help_menu, '&Help')
self.SetMenuBar(menubar)
python类ID_HELP的实例源码
def _init_coll_HelpMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_HELP,
kind=wx.ITEM_NORMAL, text=_(u'PLCOpenEditor') + '\tF1')
# AppendMenu(parent, help='', id=wx.ID_HELP_CONTENTS,
# kind=wx.ITEM_NORMAL, text=u'PLCOpen\tF2')
# AppendMenu(parent, help='', id=wx.ID_HELP_CONTEXT,
# kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3')
def handler(event):
return wx.MessageBox(
version.GetCommunityHelpMsg(),
_(u'Community support'),
wx.OK | wx.ICON_INFORMATION)
id = wx.NewId()
parent.Append(help='', id=id, kind=wx.ITEM_NORMAL, text=_(u'Community support'))
self.Bind(wx.EVT_MENU, handler, id=id)
AppendMenu(parent, help='', id=wx.ID_ABOUT,
kind=wx.ITEM_NORMAL, text=_(u'About'))
self.Bind(wx.EVT_MENU, self.OnPLCOpenEditorMenu, id=wx.ID_HELP)
# self.Bind(wx.EVT_MENU, self.OnPLCOpenMenu, id=wx.ID_HELP_CONTENTS)
self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT)
def __init__(self, parent):
wx.Dialog.__init__(self, parent, -1, title=u"Logon", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
vsizer = wx.BoxSizer(orient=wx.VERTICAL)
gb = wx.GridBagSizer()
gb.Add(wx.StaticText(self, -1, u"Username"), flag=wx.ALL|wx.EXPAND, border=10, pos=(0,0))
self._name = wx.TextCtrl(self, -1)
gb.Add(self._name, flag=wx.ALL|wx.EXPAND, border=10, pos=(0,1))
gb.Add(wx.StaticText(self, -1, u"Password"), flag=wx.ALL|wx.EXPAND, pos=(1,0), border=10)
self._pass = wx.TextCtrl(self, -1, style=wx.TE_PASSWORD)
gb.Add(self._pass, border=10, flag=wx.EXPAND|wx.ALL, pos=(1,1))
gb.AddGrowableCol(1)
butsz = wx.StdDialogButtonSizer()
okbut = wx.Button(self, wx.ID_OK, u"OK")
butsz.AddButton(okbut)
cbut = wx.Button(self, wx.ID_CANCEL, u"Cancel")
butsz.AddButton(cbut)
insp = wx.Button(self, wx.ID_HELP, u"Help")
butsz.AddButton(insp)
insp.Bind(wx.EVT_BUTTON, InspectionTool().Show)
butsz.Realize()
okbut.SetDefault()
vsizer.Add(gb, 0, wx.EXPAND)
vsizer.Add(butsz, 0, wx.EXPAND)
self.SetSizer(vsizer)
self.Fit()
def __init__(self, parent):
with iz.Dialog(init=self, title=u"Logon", orient=wx.VERTICAL, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
with iz.GridBagSizer(orient=wx.HORIZONTAL, proportion=1) as gb:
# Defaults for StaticText and TextCtrl are normally border=0,proportion=0,flag=0. Change them temporarily
# to avoid repeating the same options for each and every control:
with iz.StaticText.Default(border=10), iz.TextCtrl.Default(border=10, proportion=1, flag=wx.EXPAND):
# Now the sizer parameters can be omitted in the control definitions, since the defaults are
# now appropriate.
iz.StaticText(u"Username")
self._name = iz.TextCtrl().wx
iz.StaticText(u"Password", x=0)
self._pass = iz.TextCtrl(style=wx.TE_PASSWORD).wx
gb.AddGrowableCol(1)
with iz.StdDialogButtonSizer():
okbut = iz.Button(u"OK", id=wx.ID_OK).wx
iz.Button(u"Cancel", id=wx.ID_CANCEL)
insp = iz.Button(u"Help", id=wx.ID_HELP,border=10, EVT_BUTTON=InspectionTool().Show).wx
okbut.SetDefault()
self.Fit()
def __init__(self, parent, title):
self.dirname=os.getcwd()
wx.Frame.__init__(self, parent, title=title, size=(1000,700))
self.SetSizeHints(1000,700,-1,-1)
self.CreateStatusBar()
filemenu= wx.Menu()
menuOpen = filemenu.Append(wx.ID_OPEN, "&Open"," Open saved state")
menuSave = filemenu.Append(wx.ID_SAVE, "&Save"," Save current state")
filemenu.InsertSeparator(2)
menuNew = filemenu.Append(wx.ID_NEW, "&New"," Create new session")
filemenu.InsertSeparator(4)
menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")
viewmenu = wx.Menu()
vismenu = wx.Menu()
self.viewmenuundock = vismenu.Append(wx.ID_ANY,"&Undock","Undock the visualisation")
self.viewmenuundock.Enable(0)
self.viewmenudock = vismenu.Append(wx.ID_ANY,"&Dock","Dock the visualisation")
self.viewmenudock.Enable(0)
self.Bind(wx.EVT_MENU, self.OnUndock, self.viewmenuundock)
self.Bind(wx.EVT_MENU, self.OnDock, self.viewmenudock)
if IsNotWX4():
viewmenu.AppendMenu(wx.ID_ANY,"&Visualisation", vismenu)
else:
viewmenu.Append(wx.ID_ANY,"&Visualisation", vismenu)
self.visualdialog_docked = True
editmenu = wx.Menu()
self.menuCWD = editmenu.Append(wx.ID_ANY, "Current Working &Directory","Current Working Directory")
self.Bind(wx.EVT_MENU, self.OnCWD, self.menuCWD)
helpmenu= wx.Menu()
menuAbout= helpmenu.Append(wx.ID_ABOUT, "&About"," Information about Bonsu")
menuDoc= helpmenu.Append(wx.ID_HELP, "&Contents","Documentation")
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File")
menuBar.Append(viewmenu,"&View")
menuBar.Append(editmenu,"&Edit")
menuBar.Append(helpmenu,"&Help")
self.SetMenuBar(menuBar)
self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen)
self.Bind(wx.EVT_MENU, self.OnSave, menuSave)
self.Bind(wx.EVT_MENU, self.OnNew, menuNew)
self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
self.Bind(wx.EVT_MENU, self.OnHelp, menuDoc)
self.Bind(wx.EVT_CLOSE, self.OnExit)
self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
self.font = wx.Font(self.fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.SetFont(self.font)
icon = wx.Icon(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'image', 'bonsu.ico'), wx.BITMAP_TYPE_ICO)
wx.Frame.SetIcon(self, icon)
self.nb = None
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.Fit()
self.Layout()
self.Show()
def __init__(self, parent):
with iz.Dialog(init=self, title=u"Logon", orient=wx.VERTICAL, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
with iz.GridBagSizer(orient=wx.HORIZONTAL, proportion=1) as gb:
iz.StaticText(u"Username", border=10)
self._name = iz.TextCtrl(border=10, proportion=1, flag=wx.EXPAND).wx
iz.StaticText(u"Password", x=0, border=10)
self._pass = iz.TextCtrl(style=wx.TE_PASSWORD, border=10, proportion=1, flag=wx.EXPAND).wx
gb.AddGrowableCol(1)
with iz.StdDialogButtonSizer():
okbut = iz.Button(u"OK", id=wx.ID_OK).wx
iz.Button(u"Cancel", id=wx.ID_CANCEL)
insp = iz.Button(u"Help", id=wx.ID_HELP,border=10, EVT_BUTTON=InspectionTool().Show).wx
okbut.SetDefault()
self.Fit()
def __init__(self, app_logic, *args, **kwargs):
kwargs.setdefault('title', "Simple test App")
wx.Frame.__init__(self, *args, **kwargs)
self.app_logic = app_logic
# Build up the menu bar:
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
saveasMenuItem = fileMenu.Append(wx.ID_ANY, "&Save As", "Create a new file")
self.Bind(wx.EVT_MENU, self.onSaveAs, saveasMenuItem )
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open an existing file" )
self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem)
closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file" )
self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem)
exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
menuBar.Append(fileMenu, "&File")
helpMenu = wx.Menu()
helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help")
menuBar.Append(helpMenu, "&Help")
self.SetMenuBar(menuBar)
## add just a single button:
self.theButton = wx.Button(self, label="Push Me")
self.theButton.Bind(wx.EVT_BUTTON, self.onButton)
self.theButton.Bind(wx.EVT_RIGHT_DOWN, self.onRight)
def __init__(self, app_logic, *args, **kwargs):
kwargs.setdefault('title', "Simple test App")
wx.Frame.__init__(self, *args, **kwargs)
self.app_logic = app_logic
# put the Panel on the frame
self.buttonPanel = ButtonPanel(self)
# Build up the menu bar:
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open a file" )
self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem)
closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file" )
self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem)
exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
menuBar.Append(fileMenu, "&File")
helpMenu = wx.Menu()
helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help")
menuBar.Append(helpMenu, "&Help")
self.SetMenuBar(menuBar)
def __init__(self, app_logic, *args, **kwargs):
kwargs.setdefault('title', "Simple test App")
wx.Frame.__init__(self, *args, **kwargs)
self.app_logic = app_logic
# Add a panel so it looks correct on all platforms
self.panel = wx.Panel(self, wx.ID_ANY)
# Build up the menu bar:
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
saveasMenuItem = fileMenu.Append(wx.ID_ANY, "&Save As", "Create a new file")
self.Bind(wx.EVT_MENU, self.onSaveAs, saveasMenuItem )
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open an existing file" )
self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem)
closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file" )
self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem)
exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
menuBar.Append(fileMenu, "&File")
helpMenu = wx.Menu()
helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help")
menuBar.Append(helpMenu, "&Help")
self.SetMenuBar(menuBar)
def __init__(self, app_logic, *args, **kwargs):
kwargs.setdefault('title', "Simple test App")
wx.Frame.__init__(self, *args, **kwargs)
self.app_logic = app_logic
# Add a panel so it looks the correct on all platforms
self.panel = wx.Panel(self, wx.ID_ANY)
# Build up the menu bar:
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open a file" )
self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem)
closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file" )
self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem)
exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
menuBar.Append(fileMenu, "&File")
helpMenu = wx.Menu()
helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help")
menuBar.Append(helpMenu, "&Help")
self.SetMenuBar(menuBar)
def __init__(self, app_logic, *args, **kwargs):
kwargs.setdefault('title', "Simple test App")
wx.Frame.__init__(self, *args, **kwargs)
self.app_logic = app_logic
# put the Panel on the frame
self.buttonPanel = ButtonPanel(self)
# Build up the menu bar:
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
saveasMenuItem = fileMenu.Append(wx.ID_ANY, "&Save As", "Create a new file")
self.Bind(wx.EVT_MENU, self.onSaveAs, saveasMenuItem )
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open an existing file" )
self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem)
closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file" )
self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem)
exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
menuBar.Append(fileMenu, "&File")
helpMenu = wx.Menu()
helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help")
menuBar.Append(helpMenu, "&Help")
self.SetMenuBar(menuBar)
def __init__(self, app_logic, *args, **kwargs):
kwargs.setdefault('title', "Simple test App")
wx.Frame.__init__(self, *args, **kwargs)
self.app_logic = app_logic
# put the Panel on the frame
self.buttonPanel = MainForm(self)
# Build up the menu bar:
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
openMenuItem = fileMenu.Append(wx.ID_ANY, "&Open", "Open a file" )
self.Bind(wx.EVT_MENU, self.onOpen, openMenuItem)
closeMenuItem = fileMenu.Append(wx.ID_ANY, "&Close", "Close a file" )
self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem)
exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
menuBar.Append(fileMenu, "&File")
helpMenu = wx.Menu()
helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help")
menuBar.Append(helpMenu, "&Help")
self.SetMenuBar(menuBar)
def __init__(self, add_book, *args, **kwargs):
"""
initilizer for the main from for the AddressBook app.
:param add_book: the address book class to manipulate
:type add_book: A address_book_data.AddressBook instance
"""
kwargs.setdefault('title', "Micro Address Book")
wx.Frame.__init__(self, *args, **kwargs)
self.add_book = add_book
self.current_index = 0
# creae a status bar for messages...
self.CreateStatusBar()
# create the entryPanel
self.entryPanel = AddBookForm(add_book.book[self.current_index], self)
# put them in a Sizer to lay out
S = wx.BoxSizer(wx.VERTICAL)
S.Add(wx.StaticLine(self,style=wx.LI_HORIZONTAL), 0, wx.EXPAND)
S.Add(self.entryPanel, 0, wx.ALL|wx.EXPAND, 4)
S.Add((1,5))
S.Add(wx.StaticLine(self,style=wx.LI_HORIZONTAL), 0, wx.EXPAND)
self.SetSizerAndFit(S)
# Build up the menu bar:
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
closeMenuItem = fileMenu.Append(wx.ID_EXIT, "&Close", "Close the file" )
self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem)
exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
menuBar.Append(fileMenu, "&File")
helpMenu = wx.Menu()
helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help")
menuBar.Append(helpMenu, "&Help")
self.SetMenuBar(menuBar)