Python wx.MenuItem() Examples
The following are 23
code examples of wx.MenuItem().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: wxpython_toggle.py From R421A08-rs485-8ch-relay-board with MIT License | 6 votes |
def CreateMenuBar(self): # Create menu m_menubar = wx.MenuBar(0) # File menu m_menuFile = wx.Menu() m_menuItemQuit = wx.MenuItem(m_menuFile, wx.ID_ANY, u'&Quit' + u'\t' + u'Ctrl+Q', wx.EmptyString, wx.ITEM_NORMAL) m_menuFile.Append(m_menuItemQuit) m_menubar.Append(m_menuFile, u'&File') # About menu m_menuAbout = wx.Menu() m_menuItemAbout = wx.MenuItem(m_menuAbout, wx.ID_ANY, u'&About' + u'\t' + u'Shift+?', wx.EmptyString, wx.ITEM_NORMAL) m_menuAbout.Append(m_menuItemAbout) m_menubar.Append(m_menuAbout, u'&Help') # Set menu self.SetMenuBar(m_menubar) self.Bind(wx.EVT_MENU, self.OnMenuQuit, id=m_menuItemQuit.GetId()) self.Bind(wx.EVT_MENU, self.OnMenuAbout, id=m_menuItemAbout.GetId())
Example #2
Source File: GoSyncController.py From gosync with GNU General Public License v2.0 | 6 votes |
def CreateMenuItem(self, menu, label, func, icon=None, id=None): if id: item = wx.MenuItem(menu, id, label) else: item = wx.MenuItem(menu, -1, label) if icon: item.SetBitmap(wx.Bitmap(icon)) if id: self.Bind(wx.EVT_MENU, func, id=id) else: self.Bind(wx.EVT_MENU, func, id=item.GetId()) if wxgtk4 : menu.Append(item) else: menu.AppendItem(item) return item
Example #3
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent, plugin): self.parent = parent wx.Panel.__init__(self, parent) if plugin.moveOnDrag: self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) if plugin.iconizeOnDoubleClick: self.Bind(wx.EVT_LEFT_DCLICK, self.OnCmdIconize) self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) self.menu = menu = wx.Menu() item = wx.MenuItem(menu, wx.NewId(), "Hide") menu.AppendItem(item) menu.Bind(wx.EVT_MENU, self.OnCmdIconize, item) item = wx.MenuItem(menu, wx.NewId(),"Close") menu.AppendItem(item) menu.Bind(wx.EVT_MENU, self.OnCmdClose, item)
Example #4
Source File: frame_parser.py From iqiyi-parser with MIT License | 5 votes |
def initMenuItems(self): self.logs = wx.MenuItem(self, wx.ID_ANY, '&Logs\tF2', wx.EmptyString, wx.ITEM_NORMAL) self.settings = wx.MenuItem(self, wx.ID_ANY, 'Settings', wx.EmptyString, wx.ITEM_NORMAL) self.exit = wx.MenuItem(self, wx.ID_ANY, 'Exit', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.logs) self.AppendSeparator() self.Append(self.settings) self.AppendSeparator() self.Append(self.exit)
Example #5
Source File: relay_board_gui.py From R421A08-rs485-8ch-relay-board with MIT License | 5 votes |
def CreatePopupMenu(self): # Create popupmenu popup_menu = wx.Menu() # Add Restore/Minimize menu if self.frame.IsIconized(): menu_text = u"Restore" else: menu_text = u"Minimize" m_menuItemRestore = wx.MenuItem(popup_menu, wx.ID_ANY, menu_text, wx.EmptyString, wx.ITEM_NORMAL) popup_menu.Append(m_menuItemRestore) self.Bind(wx.EVT_MENU, self.OnTaskBarLeftClick, id=m_menuItemRestore.GetId()) # Add separator popup_menu.AppendSeparator() # Add toggle relays menu for relay in range(8): m_menuItemRelayToggle = wx.MenuItem(popup_menu, relay + 1, u"Toggle relay {}".format(relay + 1), wx.EmptyString, wx.ITEM_NORMAL) popup_menu.Append(m_menuItemRelayToggle) self.Bind(wx.EVT_MENU, self.OnRelayClick, id=m_menuItemRelayToggle.GetId()) # Add separator popup_menu.AppendSeparator() # Add Quit menu m_menuItemQuit = wx.MenuItem(popup_menu, wx.ID_ANY, u"Quit", wx.EmptyString, wx.ITEM_NORMAL) popup_menu.Append(m_menuItemQuit) self.Bind(wx.EVT_MENU, self.OnClose, id=m_menuItemQuit.GetId()) # Return popupmenu return popup_menu
Example #6
Source File: relay_board_gui.py From R421A08-rs485-8ch-relay-board with MIT License | 5 votes |
def OnContext(self, event): popup_menu = wx.Menu() m_menuItemRenameBoard = wx.MenuItem(popup_menu, wx.ID_ANY, u"Rename board (F2)", wx.EmptyString, wx.ITEM_NORMAL) popup_menu.Append(m_menuItemRenameBoard) popup_menu.AppendSeparator() m_menuItemAddBoard = wx.MenuItem(popup_menu, wx.ID_ANY, u"Add board (Ctrl+B)", wx.EmptyString, wx.ITEM_NORMAL) popup_menu.Append(m_menuItemAddBoard) m_menuItemRemoveBoard = wx.MenuItem(popup_menu, wx.ID_ANY, u"Remove board (Ctrl+D)", wx.EmptyString, wx.ITEM_NORMAL) popup_menu.Append(m_menuItemRemoveBoard) self.Bind(wx.EVT_MENU, self.OnBoardRenameClick, id=m_menuItemRenameBoard.GetId()) self.Bind(wx.EVT_MENU, self.OnBoardAddClick, id=m_menuItemAddBoard.GetId()) self.Bind(wx.EVT_MENU, self.OnBoardRemoveClick, id=m_menuItemRemoveBoard.GetId()) self.PopupMenu(popup_menu) popup_menu.Destroy()
Example #7
Source File: frame_downloader.py From iqiyi-parser with MIT License | 5 votes |
def initMenuItems(self): self.about = wx.MenuItem(self, wx.ID_ANY, '&About\tF1', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.about)
Example #8
Source File: frame_downloader.py From iqiyi-parser with MIT License | 5 votes |
def initMenuItems(self): self.logs = wx.MenuItem(self, wx.ID_ANY, '&Logs\tF2', wx.EmptyString, wx.ITEM_NORMAL) # self.parse.Enable(False) self.settings = wx.MenuItem(self, wx.ID_ANY, 'Settings', wx.EmptyString, wx.ITEM_NORMAL) # self.settings.Enable(False) self.exit = wx.MenuItem(self, wx.ID_ANY, 'Exit', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.logs) self.AppendSeparator() self.Append(self.settings) self.AppendSeparator() self.Append(self.exit)
Example #9
Source File: frame_merger.py From iqiyi-parser with MIT License | 5 votes |
def initMenuItems(self): self.logs = wx.MenuItem(self, wx.ID_ANY, '&Logs\tF2', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.logs) self.AppendSeparator() self.exit = wx.MenuItem(self, wx.ID_ANY, 'Exit', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.exit)
Example #10
Source File: listctrl.py From iqiyi-parser with MIT License | 5 votes |
def initItems(self): self.copysel = wx.MenuItem(self, wx.ID_ANY, u'复制所选项', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.copysel) self.AppendSeparator() self.copygroup = wx.MenuItem(self, wx.ID_ANY, u'复制所在组所有链接', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.copygroup)
Example #11
Source File: listctrl.py From iqiyi-parser with MIT License | 5 votes |
def initItems(self): self.godownload = wx.MenuItem(self, wx.ID_ANY, u'下载所选项', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.godownload) self.AppendSeparator() self.copylinks = wx.MenuItem(self, wx.ID_ANY, u'复制下载链接', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.copylinks) # self.copylinks.Enable(False)
Example #12
Source File: frame_parser.py From iqiyi-parser with MIT License | 5 votes |
def initMenuItems(self): self.about = wx.MenuItem(self, wx.ID_ANY, '&About\tF1', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.about) self.AppendSeparator() self.update = wx.MenuItem(self, wx.ID_ANY, 'Update Cores', wx.EmptyString, wx.ITEM_NORMAL) self.Append(self.update)
Example #13
Source File: esafenet_gui.py From E-Safenet with GNU General Public License v2.0 | 5 votes |
def __init__(self, *args, **kwds): # begin wxGlade: MainFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) # Menu Bar self.frame_2_menubar = wx.MenuBar() wxglade_tmp_menu = wx.Menu() self.opf = wx.MenuItem(wxglade_tmp_menu, wx.NewId(), "Open folder..", "", wx.ITEM_NORMAL) wxglade_tmp_menu.AppendItem(self.opf) self.opfi = wx.MenuItem(wxglade_tmp_menu, wx.NewId(), "Open file..", "", wx.ITEM_NORMAL) wxglade_tmp_menu.AppendItem(self.opfi) wxglade_tmp_menu.AppendSeparator() self.ana = wx.MenuItem(wxglade_tmp_menu, wx.NewId(), "Analyze", "", wx.ITEM_NORMAL) wxglade_tmp_menu.AppendItem(self.ana) self.frame_2_menubar.Append(wxglade_tmp_menu, "File") self.SetMenuBar(self.frame_2_menubar) # Menu Bar end self.list_ctrl_1 = wx.ListCtrl(self, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER) for i in range(512): self.list_ctrl_1.InsertColumn(i, str(i), width=30) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_MENU, self.of, self.opf) self.Bind(wx.EVT_MENU, self.anlz, self.ana) self.Bind(wx.EVT_MENU, self.ofi, self.opfi) # end wxGlade
Example #14
Source File: misc.py From wxGlade with MIT License | 5 votes |
def append_menu_item(menu, id, text, xpm_file_or_artid=None, **kwargs): # XXX change: move id to the end of the argument list? if compat.IS_CLASSIC and "helpString" in kwargs: kwargs["help"] = kwargs["helpString"] del kwargs["helpString"] item = wx.MenuItem(menu, id, text, **kwargs) if xpm_file_or_artid is not None: path = 'msw/' if wx.Platform == '__WXMSW__' else 'gtk/' path = os.path.join(config.icons_path, path) bmp = None if not isinstance(xpm_file_or_artid, bytes) or not xpm_file_or_artid.startswith(b'wxART_'): try: bmp = _item_bitmaps[xpm_file_or_artid] except KeyError: f = os.path.join(path, xpm_file_or_artid) if os.path.isfile(f): bmp = _item_bitmaps[xpm_file_or_artid] = wx.Bitmap(f, wx.BITMAP_TYPE_XPM) else: bmp = None else: # xpm_file_or_artid is an id for wx.ArtProvider bmp = wx.ArtProvider.GetBitmap( xpm_file_or_artid, wx.ART_MENU, (16, 16) ) if bmp is not None: try: item.SetBitmap(bmp) except AttributeError: pass if compat.IS_CLASSIC: menu.AppendItem(item) else: menu.Append(item) return item
Example #15
Source File: DownloadManager.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def CreatePopupMenu(self): menu = wx.Menu() if self.frame.IsShown(): toggle_label = _("Hide %s") else: toggle_label = _("Show %s") if False: toggle_item = wx.MenuItem(parentMenu=menu, id=self.TBMENU_TOGGLE, text=toggle_label%app_name, kind=wx.ITEM_NORMAL) font = toggle_item.GetFont() font.SetWeight(wx.FONTWEIGHT_BOLD) toggle_item.SetFont(font) #toggle_item.SetFont(wx.Font( # pointSize=8, # family=wx.FONTFAMILY_DEFAULT, # style=wx.FONTSTYLE_NORMAL, # weight=wx.FONTWEIGHT_BOLD)) menu.AppendItem(toggle_item) menu.AppendItem(wx.MenuItem(parentMenu=menu, id=self.TBMENU_CLOSE, text = _("Quit %s")%app_name, kind=wx.ITEM_NORMAL)) else: menu.Append(self.TBMENU_TOGGLE, toggle_label%app_name) menu.Append(self.TBMENU_CLOSE, _("Quit %s")%app_name) return menu
Example #16
Source File: bomsaway.py From Boms-Away with GNU General Public License v3.0 | 5 votes |
def _create_menu(self): menubar = wx.MenuBar() file = wx.Menu() edit = wx.Menu() help = wx.Menu() file.Append(wx.ID_OPEN, '&Open', 'Open a schematic') file.Append(wx.ID_SAVE, '&Save', 'Save the schematic') file.AppendSeparator() file.Append(103, '&Export BOM as CSV', 'Export the BOM as CSV') file.AppendSeparator() # Create a new submenu for recent files recent = wx.Menu() file.AppendSubMenu(recent, 'Recent') self.filehistory.UseMenu(recent) self.filehistory.AddFilesToMenu() file.AppendSeparator() quit = wx.MenuItem(file, 105, '&Quit\tCtrl+Q', 'Quit the Application') file.AppendItem(quit) edit.Append(201, 'Consolidate Components', 'Consolidate duplicated components') menubar.Append(file, '&File') menubar.Append(edit, '&Edit') menubar.Append(help, '&Help') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.on_quit, id=105) self.Bind(wx.EVT_MENU, self.on_open, id=wx.ID_OPEN) self.Bind(wx.EVT_MENU, self.on_consolidate, id=201) self.Bind(wx.EVT_MENU, self.on_export, id=103) self.Bind(wx.EVT_MENU, self.on_save, id=wx.ID_SAVE) self.Bind(wx.EVT_MENU_RANGE, self.on_file_history, id=wx.ID_FILE1, id2=wx.ID_FILE9)
Example #17
Source File: PyDraw.py From advancedpython3 with GNU General Public License v3.0 | 5 votes |
def __init__(self): super().__init__() file_menu = wx.Menu() new_menu_item = wx.MenuItem(file_menu, wx.ID_NEW, text="New", kind=wx.ITEM_NORMAL) new_menu_item.SetBitmap(wx.Bitmap("new.gif")) file_menu.Append(new_menu_item) load_menu_item = wx.MenuItem(file_menu, wx.ID_OPEN, text="Open", kind=wx.ITEM_NORMAL) load_menu_item.SetBitmap(wx.Bitmap("load.gif")) file_menu.Append(load_menu_item) file_menu.AppendSeparator() save_menu_item = wx.MenuItem(file_menu, wx.ID_SAVE, text="Save", kind=wx.ITEM_NORMAL) save_menu_item.SetBitmap(wx.Bitmap("save.gif")) file_menu.Append(save_menu_item) file_menu.AppendSeparator() quit = wx.MenuItem(file_menu, wx.ID_EXIT, '&Quit\tCtrl+Q') file_menu.Append(quit) self.Append(file_menu, '&File') drawing_menu = wx.Menu() line_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.LINE_ID, text="Line", kind=wx.ITEM_NORMAL) drawing_menu.Append(line_menu_item) square_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.SQUARE_ID, text="Square", kind=wx.ITEM_NORMAL) drawing_menu.Append(square_menu_item) circle_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.CIRCLE_ID, text="Circle", kind=wx.ITEM_NORMAL) drawing_menu.Append(circle_menu_item) text_menu_item = wx.MenuItem(drawing_menu, PyDrawConstants.TEXT_ID, text="Text", kind=wx.ITEM_NORMAL) drawing_menu.Append(text_menu_item) self.Append(drawing_menu, '&Drawing')
Example #18
Source File: runsnake.py From pyFileFixity with MIT License | 5 votes |
def ConfigureViewTypeChoices( self, event=None ): """Configure the set of View types in the toolbar (and menus)""" self.viewTypeTool.SetItems( getattr( self.loader, 'ROOTS', [] )) if self.loader and self.viewType in self.loader.ROOTS: self.viewTypeTool.SetSelection( self.loader.ROOTS.index( self.viewType )) # configure the menu with the available choices... def chooser( typ ): def Callback( event ): if typ != self.viewType: self.viewType = typ self.OnRootView( event ) return Callback # Clear all previous items for item in self.viewTypeMenu.GetMenuItems(): self.viewTypeMenu.DeleteItem( item ) if self.loader and self.loader.ROOTS: for root in self.loader.ROOTS: item = wx.MenuItem( self.viewTypeMenu, -1, root.title(), _("View hierarchy by %(name)s")%{ 'name': root.title(), }, kind=wx.ITEM_RADIO, ) item.SetCheckable( True ) self.viewTypeMenu.AppendItem( item ) item.Check( root == self.viewType ) wx.EVT_MENU( self, item.GetId(), chooser( root ))
Example #19
Source File: tray.py From superpaper with MIT License | 5 votes |
def create_menu_item(menu, label, func, *args, **kwargs): """Helper function to create menu items for the tray menu.""" item = wx.MenuItem(menu, -1, label, **kwargs) menu.Bind(wx.EVT_MENU, lambda event: func(event, *args), id=item.GetId()) menu.Append(item) return item
Example #20
Source File: mathtext_wx_sgskip.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(550, 350)) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, self.figure) self.change_plot(0) self.sizer = wx.BoxSizer(wx.VERTICAL) self.add_buttonbar() self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.add_toolbar() # comment this out for no toolbar menuBar = wx.MenuBar() # File Menu menu = wx.Menu() m_exit = menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample") menuBar.Append(menu, "&File") self.Bind(wx.EVT_MENU, self.OnClose, m_exit) if IS_GTK or IS_WIN: # Equation Menu menu = wx.Menu() for i, (mt, func) in enumerate(functions): bm = mathtext_to_wxbitmap(mt) item = wx.MenuItem(menu, 1000 + i, " ") item.SetBitmap(bm) menu.Append(item) self.Bind(wx.EVT_MENU, self.OnChangePlot, item) menuBar.Append(menu, "&Functions") self.SetMenuBar(menuBar) self.SetSizer(self.sizer) self.Fit()
Example #21
Source File: ndwindow.py From spectral with MIT License | 5 votes |
def __init__(self, window): super(MouseMenu, self).__init__(title='Assign to class') self.window = window self.id_classes = {} while len(self.ids) < self.window.max_menu_class + 1: self.ids.append( wx.NewId()) for i in range(self.window.max_menu_class + 1): id = self.ids[i] self.id_classes[id] = i print('(id, i) =', (id, i)) mi = wx.MenuItem(self, id, str(i)) self.AppendItem(mi) self.Bind(wx.EVT_MENU, self.reassign_points, mi)
Example #22
Source File: wm_frame.py From wafer_map with GNU General Public License v3.0 | 5 votes |
def _bind_events(self): """Bind events to varoius MenuItems.""" self.Bind(wx.EVT_MENU, self.on_quit, self.mf_close) self.Bind(wx.EVT_MENU, self.on_zoom_fit, self.mv_zoomfit) self.Bind(wx.EVT_MENU, self.on_toggle_crosshairs, self.mv_crosshairs) self.Bind(wx.EVT_MENU, self.on_toggle_diecenters, self.mv_diecenters) self.Bind(wx.EVT_MENU, self.on_toggle_outline, self.mv_outline) self.Bind(wx.EVT_MENU, self.on_toggle_legend, self.mv_legend) self.Bind(wx.EVT_MENU, self.on_change_high_color, self.mo_high_color) self.Bind(wx.EVT_MENU, self.on_change_low_color, self.mo_low_color) # If I define an ID to the menu item, then I can use that instead of # and event source: #self.mo_test = wx.MenuItem(self.mopts, 402, "&Test", "Nothing") #self.Bind(wx.EVT_MENU, self.on_zoom_fit, id=402)
Example #23
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 4 votes |
def CreateTreePopupMenu(self): """ Creates the pop-up menu for the configuration tree. """ menu = wx.Menu() text = Text.Menu def Append(ident, kind=wx.ITEM_NORMAL, image=wx.NullBitmap): item = wx.MenuItem(menu, ID[ident], getattr(text, ident), "", kind) item.SetBitmap(image) menu.AppendItem(item) return item Append("Expand", image=GetInternalBitmap("expand")) Append("Collapse", image=GetInternalBitmap("collapse")) Append("ExpandChilds", image=GetInternalBitmap("expand_children")) Append("CollapseChilds", image=GetInternalBitmap("collapse_children")) Append("ExpandAll", image=GetInternalBitmap("expand_all")) Append("CollapseAll", image=GetInternalBitmap("collapse_all")) subm = menu menu = wx.Menu() Append("Undo") Append("Redo") menu.AppendSeparator() Append("Cut") Append("Copy") Append("Python") Append("Paste") Append("Delete") menu.AppendSeparator() menu.AppendMenu(wx.ID_ANY, text=text.ExpandCollapseMenu, submenu=subm) menu.AppendSeparator() Append("AddPlugin", image=ADD_PLUGIN_ICON) Append("AddFolder", image=ADD_FOLDER_ICON) Append("AddMacro", image=ADD_MACRO_ICON) Append("AddEvent", image=ADD_EVENT_ICON) Append("AddAction", image=ADD_ACTION_ICON) menu.AppendSeparator() Append("Configure") Append("Rename") Append("Execute") menu.AppendSeparator() Append("Disabled", kind=wx.ITEM_CHECK) return menu