def create_menu(self):
filemenu = wx.Menu()
filemenu.Append(1, "Some option")
filemenu.Append(2, "Another option")
menubar = wx.MenuBar()
menubar.Append(filemenu, "&File")
self.SetMenuBar(menubar)
python类MenuBar()的实例源码
def createMenu(self):
""" Create the application's menu """
menubar = wx.MenuBar()
# Create the file menu
fileMenu = wx.Menu()
# Append the close item
# Append takes an id, the text label, and a string
# to display in the statusbar when the item is selected
close_menu_item = fileMenu.Append(wx.NewId(),
"&Close",
"Closes the application")
# Bind an event to the menu item
self.Bind(wx.EVT_MENU, self.onClose, close_menu_item)
# Add the fileMenu to the menu bar
menubar.Append(fileMenu, "&File")
# Create the help menu
helpMenu = wx.Menu()
about_menu_item = helpMenu.Append(wx.NewId(),
"&About",
"Opens the About Box")
self.Bind(wx.EVT_MENU, self.onAboutDlg, about_menu_item)
menubar.Append(helpMenu, "&Help")
# Add the menu bar to the frame
self.SetMenuBar(menubar)
def createMenu(self):
""" Create the application's menu """
menubar = wx.MenuBar()
# Create the file menu
fileMenu = wx.Menu()
# Append the close item
# Append takes an id, the text label, and a string
# to display in the statusbar when the item is selected
close_menu_item = fileMenu.Append(wx.NewId(),
"&Close",
"Closes the application")
# Bind an event to the menu item
self.Bind(wx.EVT_MENU, self.onClose, close_menu_item)
# Add the fileMenu to the menu bar
menubar.Append(fileMenu, "&File")
# Create the help menu
helpMenu = wx.Menu()
about_menu_item = helpMenu.Append(wx.NewId(),
"&About",
"Opens the About Box")
self.Bind(wx.EVT_MENU, self.onAboutDlg, about_menu_item)
menubar.Append(helpMenu, "&Help")
# Add the menu bar to the frame
self.SetMenuBar(menubar)
def create_preorder(self):
self.w = wx.MenuBar(self.style)
def create_preorder(self):
if self.menu is None:
self.menu = wx.Menu()
if not isinstance(self.zparent, (TopLevelMenu,Menu)):
raise TypeError('wize.Menu nests under wize.MenuBar,wize.PopupMenu and wize.Menu, not %s' % (type(self.zparent,)))
if isinstance(self.zparent, MenuBar):
self.zparent.w.Append(self.menu, self.label)
self.w = self.menu # there's no way to Enable/Disable wx.MenuBar top-level menus?!
else:
self.w = self.zparent.menu.AppendSubMenu(self.menu, self.label, self.help)
def __init__(self, *args, **kwargs):
self.filename = None
super(LISImportFrame, self).__init__(*args, **kwargs)
self.SetTitle('GRIPy LIS Loader')
self.panel = wx.Panel(self)
self.menu_bar = wx.MenuBar()
file_menu = wx.Menu()
file_menu.Append(wx.ID_OPEN, u"&Open LIS File")
self.Bind(wx.EVT_MENU, self.on_open, id=wx.ID_OPEN)
self.menu_bar.Append(file_menu, u"&File")
self.SetMenuBar(self.menu_bar)
self.status_bar = self.CreateStatusBar()
self.model = None
self.dvc = None
self._OM = ObjectManager(self)
def __init__(self, controller_uid):
UIViewBase.__init__(self, controller_uid)
wx.MenuBar.__init__(self)
UIM = UIManager()
parent_uid = UIM._getparentuid(controller_uid)
parent = UIM.get(parent_uid)
parent.view.SetMenuBar(self)
#class_full_name = str(self.__class__.__module__) + '.' + str(self.__class__.__name__)
#log.debug('Successfully created View object from class: {}.'.format(class_full_name))
def __init__(self):
global myWindow
wx.Frame.__init__(self, None, -1, "MQTT Protocol Trace", size=(600, 400))
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OpenDetails)
self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
self.statusBar = self.CreateStatusBar()
menubar = wx.MenuBar()
menu1 = wx.Menu()
clear = menu1.Append(wx.NewId(), "&Clear")
self.Bind(wx.EVT_MENU, self.OnClear, clear)
saveas = menu1.Append(wx.NewId(), "&Save as")
self.Bind(wx.EVT_MENU, self.OnSaveAs, saveas)
menubar.Append(menu1, "&File")
self.SetMenuBar(menubar)
for index, title in enumerate(cols):
self.list.InsertColumn(index, title)
self.list.SetColumnWidth(index, widths[index])
self.listitem = 0
listmix.ColumnSorterMixin.__init__(self, len(cols))
self.itemDataMap = {}
myWindow = self
self.thread = WorkerThread()
self.thread.start()
def _init_utils(self):
# generated method, don't edit
self.menuFile = wx.Menu(title=u'')
self.menuView = wx.Menu(title=u'')
self.menuHelp = wx.Menu(title=u'')
self.TMenuBar = wx.MenuBar()
self._init_coll_menuFile_Items(self.menuFile)
self._init_coll_menuView_Items(self.menuView)
self._init_coll_menuHelp_Items(self.menuHelp)
self._init_coll_TMenuBar_Menus(self.TMenuBar)
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 createMenus(self):
# Creating the menubar.
menuBar = wx.MenuBar()
# Setting up the 'File' menu.
self.menuFile = wx.Menu()
self.menuFile.Append(ID_MENU_FILE_EXIT, "E&xit"," Terminate this program")
menuBar.Append(self.menuFile,"&File")
# Setting up the 'Phonebook' menu.
self.menuPhonebook = wx.Menu()
self.menuPhonebook.Append(ID_MENU_PHONEBOOK_ADN, "Phonebook (ADN)"," Manage your phonebook (Abbreviated Dial Numbers)")
self.menuPhonebook.Append(ID_MENU_PHONEBOOK_FDN, "Fixed Dialing Numbers (FDN)"," Manage your Fixed Dialing Numbers")
self.menuPhonebook.Append(ID_MENU_LND, "Last # dialed (LND)"," Manage your Fixed Dialing Numbers")
menuBar.Append(self.menuPhonebook,"&Phonebook")
# Setting up the 'SMS' menu.
self.menuMessages = wx.Menu()
self.menuMessages.Append(ID_MENU_SMS, "SMS"," Manage your SMS messages")
menuBar.Append(self.menuMessages,"&Messages")
# Setting up the 'SIM' menu.
self.menuSIM = wx.Menu()
self.menuSIM.Append(ID_MENU_SIM_INFO, "SIM Information"," Information about your SIM card")
self.menuSIM.AppendSeparator()
self.menuSIM.Append(ID_MENU_SIM_PIN_CHANGE, "Change PIN"," Change your PIN code (CHV1)")
self.menuSIM.Append(ID_MENU_SIM_PIN_ENABLE, "Enable PIN"," Prompt for PIN when turning on phone")
self.menuSIM.Append(ID_MENU_SIM_PIN_DISABLE, "Disable PIN"," Remove the PIN prompt when turning on phone")
#self.menuSIM.AppendSeparator()
#self.menuSIM.Append(ID_MENU_SIM_BACKUP, "Backup"," Backup your SIM information")
#self.menuSIM.Append(ID_MENU_SIM_RESTORE, "Restore"," Restore your SIM information from a previous backup")
menuBar.Append(self.menuSIM, "&SIM")
# Setting up the menu.
self.menuHelp = wx.Menu()
self.menuHelp.Append(ID_MENU_HELP_HELP, "&Help"," Help documentation")
self.menuHelp.AppendSeparator()
self.menuHelp.Append(ID_MENU_HELP_ABOUT, "&About"," Information about this program")
menuBar.Append(self.menuHelp,"&Help")
# Adding the MenuBar to the Frame content.
self.SetMenuBar(menuBar)
#Add the menu handlers
wx.EVT_MENU(self, ID_MENU_FILE_EXIT, self.closeWindow)
wx.EVT_MENU(self, ID_MENU_PHONEBOOK_ADN, self.buttonPhonebook)
wx.EVT_MENU(self, ID_MENU_PHONEBOOK_FDN, self.buttonFDN)
wx.EVT_MENU(self, ID_MENU_LND, self.buttonLND)
wx.EVT_MENU(self, ID_MENU_SMS, self.buttonSMS)
wx.EVT_MENU(self, ID_MENU_SIM_INFO, self.menuSIMInfo)
wx.EVT_MENU(self, ID_MENU_SIM_PIN_CHANGE, self.menuChangePIN)
wx.EVT_MENU(self, ID_MENU_SIM_PIN_ENABLE, self.menuEnablePIN)
wx.EVT_MENU(self, ID_MENU_SIM_PIN_DISABLE, self.menuDisablePIN)
wx.EVT_MENU(self, ID_MENU_HELP_HELP, self.menuHelpHelp)
wx.EVT_MENU(self, ID_MENU_HELP_ABOUT, self.menuHelpAbout)
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title,
pos=(150, 150), size=(350, 200))
# Create the menubar
menuBar = wx.MenuBar()
# and a menu
menu = wx.Menu()
# add an item to the menu, using \tKeyName automatically
# creates an accelerator, the third param is some help text
# that will show up in the statusbar
menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
# bind the menu event to an event handler
self.Bind(wx.EVT_MENU, self.on_time_to_close, id=wx.ID_EXIT)
# and put the menu on the menubar
menuBar.Append(menu, "&File")
self.SetMenuBar(menuBar)
self.CreateStatusBar()
# Now create the Panel to put the other controls on.
panel = wx.Panel(self)
# and a few controls
text = wx.StaticText(panel, -1, "Hello World!")
text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
text.SetSize(text.GetBestSize())
btn = wx.Button(panel, -1, "Close")
funbtn = wx.Button(panel, -1, "Just for fun...")
# bind the button events to handlers
self.Bind(wx.EVT_BUTTON, self.on_time_to_close, btn)
self.Bind(wx.EVT_BUTTON, self.on_fun_button, funbtn)
# Use a sizer to layout the controls, stacked vertically and with
# a 10 pixel border around each
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(text, 0, wx.ALL, 10)
sizer.Add(btn, 0, wx.ALL, 10)
sizer.Add(funbtn, 0, wx.ALL, 10)
panel.SetSizer(sizer)
panel.Layout()
def __init__(self, parent, title):
"""Create the pydicom image example's main frame window."""
wx.Frame.__init__(self, parent, id=-1, title="", pos=wx.DefaultPosition,
size=wx.Size(w=1024, h=768),
style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN)
# --------------------------------------------------------
# Set up the menubar.
# --------------------------------------------------------
self.mainmenu = wx.MenuBar()
# Make the 'File' menu.
menu = wx.Menu()
item = menu.Append(wx.ID_ANY, '&Open', 'Open file for editing')
self.Bind(wx.EVT_MENU, self.OnFileOpen, item)
item = menu.Append(wx.ID_ANY, 'E&xit', 'Exit Program')
self.Bind(wx.EVT_MENU, self.OnFileExit, item)
self.mainmenu.Append(menu, '&File')
# Attach the menu bar to the window.
self.SetMenuBar(self.mainmenu)
# --------------------------------------------------------
# Set up the main splitter window.
# --------------------------------------------------------
self.mainSplitter = wx.SplitterWindow(self, style=wx.NO_3D | wx.SP_3D)
self.mainSplitter.SetMinimumPaneSize(1)
# -------------------------------------------------------------
# Create the folderTreeView on the left.
# -------------------------------------------------------------
self.dsTreeView = wx.TreeCtrl(self.mainSplitter, style=wx.TR_LINES_AT_ROOT | wx.TR_HAS_BUTTONS)
# --------------------------------------------------------
# Create the ImageView on the right pane.
# --------------------------------------------------------
self.imView = wx.Panel(self.mainSplitter, style=wx.VSCROLL | wx.HSCROLL | wx.CLIP_CHILDREN)
self.imView.Bind(wx.EVT_PAINT, self.OnPaint)
self.imView.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.imView.Bind(wx.EVT_SIZE, self.OnSize)
# --------------------------------------------------------
# Install the splitter panes.
# --------------------------------------------------------
self.mainSplitter.SplitVertically(self.dsTreeView, self.imView)
self.mainSplitter.SetSashPosition(300, True)
# --------------------------------------------------------
# Initialize some values
# --------------------------------------------------------
self.dcmdsRoot = False
self.foldersRoot = False
self.loadCentered = True
self.bitmap = None
self.Show(True)
def SetMenu(self):
menu1 = wx.Menu()
menu2=wx.Menu()
menu3=wx.Menu()
menu5=wx.Menu()
menu4=wx.Menu()
menu6=wx.Menu()
menu7=wx.Menu()
menu1.Append(110, "&Exit")
menu2.Append(115, "&Complete Report")#sub
menu2.Append(116, "&Second Term Only") #sub
menu3.AppendMenu(180, "&Progress Report",menu2)
menu3.Append(118, "P&romotion List")
menu3.Append(117, "C&ustom Reports")
#menu6.Append(116, "&Statistics")
menuBar = wx.MenuBar()
menuBar.Append(menu1, "&File");
menuBar.Append(menu3, "&Reports");
self.SetMenuBar(menuBar)
wx.EVT_MENU(self, 110, self.OnMenu_Exit)
wx.EVT_MENU(self, 115, self.OnMenu_PerformanceReport)
wx.EVT_MENU(self, 116, self.OnMenu_Performance_T2_Only)
wx.EVT_MENU(self, 117, self.OnMenu_Custom)
wx.EVT_MENU(self, 118, self.OnPromotion_List)
def __init__(self, parent, title):
"""Create the pydicom image example's main frame window."""
wx.Frame.__init__(self, parent, id=-1, title="", pos=wx.DefaultPosition,
size=wx.Size(w=1024, h=768),
style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN)
# --------------------------------------------------------
# Set up the menubar.
# --------------------------------------------------------
self.mainmenu = wx.MenuBar()
# Make the 'File' menu.
menu = wx.Menu()
item = menu.Append(wx.ID_ANY, '&Open', 'Open file for editing')
self.Bind(wx.EVT_MENU, self.OnFileOpen, item)
item = menu.Append(wx.ID_ANY, 'E&xit', 'Exit Program')
self.Bind(wx.EVT_MENU, self.OnFileExit, item)
self.mainmenu.Append(menu, '&File')
# Attach the menu bar to the window.
self.SetMenuBar(self.mainmenu)
# --------------------------------------------------------
# Set up the main splitter window.
# --------------------------------------------------------
self.mainSplitter = wx.SplitterWindow(self, style=wx.NO_3D | wx.SP_3D)
self.mainSplitter.SetMinimumPaneSize(1)
# -------------------------------------------------------------
# Create the folderTreeView on the left.
# -------------------------------------------------------------
self.dsTreeView = wx.TreeCtrl(self.mainSplitter, style=wx.TR_LINES_AT_ROOT | wx.TR_HAS_BUTTONS)
# --------------------------------------------------------
# Create the ImageView on the right pane.
# --------------------------------------------------------
self.imView = wx.Panel(self.mainSplitter, style=wx.VSCROLL | wx.HSCROLL | wx.CLIP_CHILDREN)
self.imView.Bind(wx.EVT_PAINT, self.OnPaint)
self.imView.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.imView.Bind(wx.EVT_SIZE, self.OnSize)
# --------------------------------------------------------
# Install the splitter panes.
# --------------------------------------------------------
self.mainSplitter.SplitVertically(self.dsTreeView, self.imView)
self.mainSplitter.SetSashPosition(300, True)
# --------------------------------------------------------
# Initialize some values
# --------------------------------------------------------
self.dcmdsRoot = False
self.foldersRoot = False
self.loadCentered = True
self.bitmap = None
self.Show(True)