我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.EVT_MENU。
def _build_menu_bar(self): self.menuBar = wx.MenuBar() # File menu file_menu = wx.Menu() wx.App.SetMacExitMenuItemId(wx.ID_EXIT) exit_item = file_menu.Append(wx.ID_EXIT, "E&xit\tCtrl-Q", "Exit NodeMCU PyFlasher") exit_item.SetBitmap(images.Exit.GetBitmap()) self.Bind(wx.EVT_MENU, self._on_exit_app, exit_item) self.menuBar.Append(file_menu, "&File") # Help menu help_menu = wx.Menu() help_item = help_menu.Append(wx.ID_ABOUT, '&About NodeMCU PyFlasher', 'About') self.Bind(wx.EVT_MENU, self._on_help_about, help_item) self.menuBar.Append(help_menu, '&Help') self.SetMenuBar(self.menuBar)
def OnInit(self): frame = wx.Frame(None, -1, "RunDemo: ", pos=(0,0), style=wx.DEFAULT_FRAME_STYLE, name="run a sample") menuBar = wx.MenuBar() menu = wx.Menu() item = menu.Append(wx.ID_EXIT, "E&xit", "Exit demo") self.Bind(wx.EVT_MENU, self.OnExitApp, item) menuBar.Append(menu, "&File") frame.SetMenuBar(menuBar) frame.Show(True) frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame) win = runTest(frame) # set the frame to a good size for showing the two buttons frame.SetSize((200,400)) win.SetFocus() self.window = win frect = frame.GetRect() self.SetTopWindow(frame) self.frame = frame return True
def createMenus(self): # Creating the menubar. menuBar = wx.MenuBar() # Setting up the menu. filemenu = wx.Menu() filemenu.Append(ID_MENU_FILE_READ, "Read"," Read last numbers dialed SIM.") filemenu.AppendSeparator() filemenu.Append(ID_MENU_FILE_EXPORT, "Export..."," Export your LND to file") filemenu.Append(ID_MENU_FILE_IMPORT, "Import..."," Import your LND from file") filemenu.AppendSeparator() filemenu.Append(ID_MENU_FILE_EXIT, "Close"," Close the lnd") # Adding the "filemenu" to the MenuBar menuBar.Append(filemenu,"&File") # Adding the MenuBar to the Frame content. self.SetMenuBar(menuBar) #Add the menu handlers wx.EVT_MENU(self, ID_MENU_FILE_READ, self.read) wx.EVT_MENU(self, ID_MENU_FILE_EXPORT, self.doExport) wx.EVT_MENU(self, ID_MENU_FILE_IMPORT, self.doImport) wx.EVT_MENU(self, ID_MENU_FILE_EXIT, self.closeWindow)
def createMenus(self): # Creating the menubar. menuBar = wx.MenuBar() # Setting up the menu. filemenu = wx.Menu() filemenu.Append(ID_MENU_FILE_READ, "Read"," Read your phonebook contacts from your SIM.") filemenu.AppendSeparator() filemenu.Append(ID_MENU_FILE_EXPORT, "Export..."," Export your phone contacts to file") filemenu.Append(ID_MENU_FILE_IMPORT, "Import..."," Import your phone contacts from file") filemenu.AppendSeparator() filemenu.Append(ID_MENU_FILE_EXIT, "Close"," Close the phonebook") # Adding the "filemenu" to the MenuBar menuBar.Append(filemenu,"&File") # Adding the MenuBar to the Frame content. self.SetMenuBar(menuBar) #Add the menu handlers wx.EVT_MENU(self, ID_MENU_FILE_READ, self.read) wx.EVT_MENU(self, ID_MENU_FILE_EXPORT, self.doExport) wx.EVT_MENU(self, ID_MENU_FILE_IMPORT, self.doImport) wx.EVT_MENU(self, ID_MENU_FILE_EXIT, self.closeWindow)
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)
def init_settings_popup_menu(self): menu = wx.Menu() menu.Append(wx.NewId(), 'Show in GUI:').Enable(False) wx_id = wx.NewId() self.settings_menu_sky_item = menu.AppendCheckItem(wx_id, ' Sky') wx.EVT_MENU(menu, wx_id, self.on_settings_menu_sky_item) self.settings_menu_sky_item.Check(True) wx_id = wx.NewId() self.settings_menu_flat_item = menu.AppendCheckItem(wx_id, ' Flat') wx.EVT_MENU(menu, wx_id, self.on_settings_menu_flat_item) self.settings_menu_flat_item.Check(True) wx_id = wx.NewId() self.settings_menu_autoload_item = menu.AppendCheckItem(wx_id, ' Auto-load') wx.EVT_MENU(menu, wx_id, self.on_settings_menu_autoload_item) self.settings_menu_autoload_item.Check(True) wx_id = wx.NewId() self.settings_menu_activemq_item = menu.AppendCheckItem(wx_id, ' ActiveMQ') wx.EVT_MENU(menu, wx_id, self.on_settings_menu_activemq_item) self.settings_menu_activemq_item.Check(True) self.settings_popup_menu = menu
def init_cmap_popup_menu(self): cmap_button_bitmap_height = 10 cmap_button_bitmap_width = 200 cmap_menu_bitmap_height = 20 cmap_menu_bitmap_width = 200 self.cmap_button_bitmaps = {} self.cmap_menu_bitmaps = {} for cmap in self.ztv_frame.available_cmaps: temp = cm.ScalarMappable(cmap=cmap) rgba = temp.to_rgba(np.outer(np.ones(cmap_button_bitmap_height, dtype=np.uint8), np.arange(cmap_button_bitmap_width, dtype=np.uint8))) self.cmap_button_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_button_bitmap_width, cmap_button_bitmap_height, np.uint8(np.round(rgba*255))) rgba = temp.to_rgba(np.outer(np.ones(cmap_menu_bitmap_height, dtype=np.uint8), np.arange(cmap_menu_bitmap_width, dtype=np.uint8))) self.cmap_menu_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_menu_bitmap_width, cmap_menu_bitmap_height, np.uint8(np.round(rgba*255))) menu = wx.Menu() for cmap in self.ztv_frame.available_cmaps: menu_item = menu.AppendCheckItem(self.cmap_to_eventID[cmap], cmap) wx.EVT_MENU(menu, self.cmap_to_eventID[cmap], self.on_change_cmap_event) if hasattr(menu_item, 'SetBitmap'): menu_item.SetBitmap(self.cmap_menu_bitmaps[cmap]) self.cmap_popup_menu = menu
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 ResetEditorToolBar(self): EditorToolBar = self.Panes["EditorToolBar"] for item in self.CurrentEditorToolBar: if wx.VERSION >= (2, 6, 0): self.Unbind(wx.EVT_MENU, id=item) else: self.Disconnect(id=item, eventType=wx.wxEVT_COMMAND_MENU_SELECTED) if EditorToolBar: EditorToolBar.DeleteTool(item) if EditorToolBar: EditorToolBar.Realize() self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) self.AUIManager.GetPane("EditorToolBar").Hide() self.AUIManager.Update()
def GenerateTreeMenu(self, x, y, scaling, menu, base_path, var_class, tree): for child_name, child_type, (child_tree, child_dimensions) in tree: if base_path: child_path = "%s.%s" % (base_path, child_name) else: child_path = child_name if len(child_dimensions) > 0: child_path += "[%s]" % ",".join([str(dimension[0]) for dimension in child_dimensions]) child_name += "[]" new_id = wx.NewId() AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=child_name) self.ParentWindow.Bind(wx.EVT_MENU, self.GetAddVariableBlockFunction(x, y, scaling, var_class, child_path, child_type), id=new_id) if len(child_tree) > 0: new_id = wx.NewId() child_menu = wx.Menu(title='') self.GenerateTreeMenu(x, y, scaling, child_menu, child_path, var_class, child_tree) menu.AppendMenu(new_id, "%s." % child_name, child_menu)
def PopupForceMenu(self): iec_path = self.GetElementIECPath(self.SelectedElement) if iec_path is not None: menu = wx.Menu(title='') new_id = wx.NewId() AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value")) self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.SelectedElement), id=new_id) new_id = wx.NewId() AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value")) self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id) if self.SelectedElement.IsForced(): menu.Enable(new_id, True) else: menu.Enable(new_id, False) if self.Editor.HasCapture(): self.Editor.ReleaseMouse() self.Editor.PopupMenu(menu) menu.Destroy()
def __init__(self, pyroserver, level): wx.TaskBarIcon.__init__(self) self.pyroserver = pyroserver # Set the image self.UpdateIcon(None) self.level = level # bind some events self.Bind(wx.EVT_MENU, self.OnTaskBarStartPLC, id=self.TBMENU_START) self.Bind(wx.EVT_MENU, self.OnTaskBarStopPLC, id=self.TBMENU_STOP) self.Bind(wx.EVT_MENU, self.OnTaskBarChangeName, id=self.TBMENU_CHANGE_NAME) self.Bind(wx.EVT_MENU, self.OnTaskBarChangeInterface, id=self.TBMENU_CHANGE_INTERFACE) self.Bind(wx.EVT_MENU, self.OnTaskBarLiveShell, id=self.TBMENU_LIVE_SHELL) self.Bind(wx.EVT_MENU, self.OnTaskBarWXInspector, id=self.TBMENU_WXINSPECTOR) self.Bind(wx.EVT_MENU, self.OnTaskBarChangePort, id=self.TBMENU_CHANGE_PORT) self.Bind(wx.EVT_MENU, self.OnTaskBarChangeWorkingDir, id=self.TBMENU_CHANGE_WD) self.Bind(wx.EVT_MENU, self.OnTaskBarQuit, id=self.TBMENU_QUIT)
def __init__(self, app): self.model = Model() self.model.attach(self) self.frame = MainFrame() self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.central_panel = None self.frame.SetSizer(self.sizer) self.frame.Layout() self.config_check = -1 self.frame.Bind(wx.EVT_MENU, lambda event: self.create_central_panel(event, False), self.frame.training_rec_menu_item) self.frame.Bind(wx.EVT_MENU, lambda event: self.create_central_panel(event, True), self.frame.start_rec_menu_item) self.frame.Bind(wx.EVT_MENU, self.create_dialog_max_time, self.frame.max_time_menu_item) self.frame.Bind(wx.EVT_MENU, self.create_dialog_partial_time, self.frame.partial_time_menu_item) self.frame.Bind(wx.EVT_MENU, self.create_dialog_partial_time, self.frame.sett3) Publisher().subscribe(self.update_status, "update_status") Publisher().subscribe(self.create_dialog_speaker_name, "crea_dialog") Publisher().subscribe(self.update_speakers_list, "update_speakers_list") Publisher().subscribe(self.clear_speakers_list, "clear_speakers_list") Publisher().subscribe(self.toogle_stop_button, "toogle_button")
def on_field_view_ready(self, dispatcher, view): assert view is not None view.Bind(EVT_MENU, self.imp.on_addr_rel, id=XRCID('field_menu_address_relative')) view.Bind(EVT_MENU, self.imp.on_addr_abs, id=XRCID('field_menu_address_absolute')) view.Bind(EVT_MENU, self.imp.on_addr_hex, id=XRCID('field_menu_address_base_hex')) view.Bind(EVT_MENU, self.imp.on_addr_dec, id=XRCID('field_menu_address_base_dec')) view.Bind(EVT_MENU, self.imp.on_dump_to_disk, id=XRCID('field_menu_dump_to_disk')) view.Bind(EVT_MENU, self.imp.on_parse_substream, id=XRCID('field_menu_parse_substream')) view.Bind(EVT_MENU, self.imp.on_open_window_here, id=XRCID('field_menu_open_window_here'))
def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "Panel Switcher Tutorial") self.panel_one = PanelOne(self) self.panel_two = PanelTwo(self) self.panel_two.Hide() self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.panel_one, 1, wx.EXPAND) self.sizer.Add(self.panel_two, 1, wx.EXPAND) self.SetSizer(self.sizer) menubar = wx.MenuBar() fileMenu = wx.Menu() switch_panels_menu_item = fileMenu.Append( wx.ID_ANY, "Switch Panels", "Some text") self.Bind(wx.EVT_MENU, self.onSwitchPanels, switch_panels_menu_item) menubar.Append(fileMenu, '&File') self.SetMenuBar(menubar)
def __init__(self): wx.TaskBarIcon.__init__(self) self.SetIcon(AppResource.TaskIcon.getIcon(), C_APP_NAME) self.ID_NAME = wx.NewId() self.ID_EXIT = wx.NewId() self.ID_AUTHOR = wx.NewId() self.Bind(wx.EVT_MENU, self.OnExitEvent, id=self.ID_EXIT) self.Bind(wx.EVT_MENU, self.OnHelpEvent, id=self.ID_AUTHOR)
def createMenu(self): menu= wx.Menu() menu.Append(wx.ID_NEW, "New", "Create something new") menu.AppendSeparator() _exit = menu.Append(wx.ID_EXIT, "Exit", "Exit the GUI") self.Bind(wx.EVT_MENU, self.exitGUI, _exit) menuBar = wx.MenuBar() menuBar.Append(menu, "File") menu1= wx.Menu() menu1.Append(wx.ID_ABOUT, "About", "wxPython GUI") menuBar.Append(menu1, "Help") self.SetMenuBar(menuBar) #----------------------------------------------------------
def createMenu(self, menuData): menu = wx.Menu() for eachLabel, eachStatus, eachHandler in menuData: if not eachLabel: menu.AppendSeparator() continue menuItem = menu.Append(-1, eachLabel, eachStatus) self.Bind(wx.EVT_MENU, eachHandler, menuItem) return menu ############################################################################ # # Handling methods, rather self explaining #
def CreateMenuBar(self): menubar = wx.MenuBar() fileMenu = wx.Menu() nitem = fileMenu.Append(wx.ID_NEW, '&New', 'New project' ) oitem = fileMenu.Append(wx.ID_OPEN, '&Open', 'Open project') self.ritem = fileMenu.Append(wx.ID_SAVEAS, '&Render\tCtrl-r', 'Render') self.iitem = fileMenu.Append(wx.ID_ANY, '&Import\tCtrl-i', 'Import image directory') self.qitem = fileMenu.Append(wx.ID_EXIT, '&Quit', 'Quit application') editMenu = wx.Menu() self.zitem = editMenu.Append(wx.ID_UNDO, '&Undo\tCtrl-z', 'Undo Delete') #yitem = editMenu.Append(wx.ID_REDO, '&Redo', 'Redo') self.ditem = editMenu.Append(wx.ID_DELETE, '&Delete\tDelete', 'Delete') pitem = editMenu.Append(wx.ID_PREFERENCES, '&Preferences\tCtrl-,', 'Preferences') helpMenu = wx.Menu() aitem = helpMenu.Append(wx.ID_ABOUT, '&About\tCtrl-?', 'About Stopgo') menubar.Append(fileMenu, '&File') menubar.Append(editMenu, '&Edit') menubar.Append(helpMenu, '&Help') self.Bind(wx.EVT_MENU, lambda event, args=(False): self.OpenFile(event,args), oitem) self.Bind(wx.EVT_MENU, self.NewFile, nitem) self.Bind(wx.EVT_MENU, self.Pref, pitem) self.Bind(wx.EVT_MENU, lambda event,args=(False): ingest.Ingest(self),self.iitem) self.Bind(wx.EVT_MENU, self.SimpleQuit, self.qitem) self.Bind(wx.EVT_CLOSE, self.SimpleQuit, self.qitem) self.Bind(wx.EVT_MENU, self.About, aitem) self.SetMenuBar(menubar)
def BindKeys(self,dbfile): ''' Bind keyboard shortcuts for application. ''' self.Bind(wx.EVT_MENU, lambda event, args=('MENU_DEL',dbfile): self.OnKeyDown(event,args), self.ditem) self.Bind(wx.EVT_MENU, lambda event, args=dbfile: self.Undo(event,args), self.zitem) self.Bind(wx.EVT_BUTTON, lambda event, args=('wx.WXK_SPACE',dbfile): self.OnKeyDown(event,args), self.bplay) self.Bind(wx.EVT_BUTTON, lambda event, args=(dbfile): self.CaptureCanvas(event,args), self.brec) self.panel3.Bind(wx.EVT_KEY_DOWN, lambda event, args=(dbfile): self.OnKeyDown(event, args)) self.panel3.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick) self.Bind(wx.EVT_MENU, lambda event, args=(dbfile):self.OnQuit(event,args), self.qitem) self.Bind(wx.EVT_CLOSE, lambda event, args=(dbfile):self.OnQuit(event,args), self.qitem) self.Bind(wx.EVT_MENU, lambda event, args=(dbfile):self.OnRender(event,args), self.ritem)
def OnRightClick(self, event): menu = wx.Menu() tPopupID0 = wx.NewId() tPopupID1 = wx.NewId() tPopupID2 = wx.NewId() tPopupID3 = wx.NewId() tPopupID4 = wx.NewId() tPopupID5 = wx.NewId() menu.Append(tPopupID2, "Edit") menu.Append(tPopupID0, "New") menu.Append(tPopupID1, "Copy") menu.AppendSeparator() menu.Append(tPopupID3, "Delete") menu.Append(tPopupID4, "Delete All") wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit) wx.EVT_MENU(self, tPopupID0, self.OnPopupNew) wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy) wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete) wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll) if len(self.itemDataMap) == 0: for m in menu.GetMenuItems(): m.Enable(False) m = menu.FindItemById(tPopupID0) m.Enable(True) self.PopupMenu(menu, wx.Point(self.x, self.y)) menu.Destroy() event.Skip()
def OnRightClick(self, event): tsubPopupID1 = 10 tsubPopupID2 = 11 tsubPopupID3 = 12 submenu = wx.Menu() submenu.Append(tsubPopupID1, "Read") submenu.Append(tsubPopupID2, "Unread") submenu.Append(tsubPopupID3, "Deleted") wx.EVT_MENU(self, tsubPopupID1, self.OnPopupMarkRead) wx.EVT_MENU(self, tsubPopupID2, self.OnPopupMarkUnread) wx.EVT_MENU(self, tsubPopupID3, self.OnPopupMarkDeleted) menu = wx.Menu() tPopupID0 = wx.NewId() tPopupID1 = wx.NewId() tPopupID2 = wx.NewId() tPopupID3 = wx.NewId() tPopupID4 = wx.NewId() tPopupID5 = wx.NewId() menu.AppendMenu(tPopupID1, "Mark as", submenu) menu.AppendSeparator() menu.Append(tPopupID2, "Edit") menu.Append(tPopupID0, "New") menu.Append(tPopupID1, "Copy") menu.AppendSeparator() menu.Append(tPopupID3, "Delete") menu.Append(tPopupID4, "Delete All") wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit) wx.EVT_MENU(self, tPopupID0, self.OnPopupNew) wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy) wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete) wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll) self.PopupMenu(menu, wx.Point(self.x, self.y)) menu.Destroy() event.Skip()
def _unbindfuncs(self): # I would need a list of the functions that been bound to unbind them while True: try: widget, event, dynboundmethod = self._dynbindings.pop() except IndexError: break # no more items in the list else: if event in [wx.EVT_MENU, wx.EVT_TOOL]: self.Unbind(event, handler=dynboundmethod, id=widget.GetId()) elif event in [wx.EVT_SIZE]: self.Unbind(event, handler=dynboundmethod) else: widget.Unbind(event, handler=dynboundmethod)
def _bindfuncs(self): # wx classes throw exception if getmember is applied to the instance (self) methods = inspect.getmembers(self.__class__, inspect.ismethod) for mname, method in methods: dynbindings = getattr(method, '_dynbinding', None) if dynbindings is None: continue for dynbinding in dynbindings: if dynbinding: eventname, widgetprefix, widgetname = dynbinding event = getattr(wx, eventname, None) if event is None: print 'Method', mname print 'Failed to find eventname', eventname continue name = 'm_' + widgetprefix.lower() + widgetname.lower() widget = None for attrname in dir(self): if attrname.lower() == name: widget = getattr(self, attrname) break if not widget: print 'Method', mname print 'Failed to find widget', name continue boundmethod = method.__get__(self, self.__class__) self._dynbindings.append((widget, event, boundmethod)) if event in [wx.EVT_MENU, wx.EVT_TOOL]: self.Bind(event, boundmethod, id=widget.GetId()) elif event in [wx.EVT_SIZE]: self.Bind(event, boundmethod) else: widget.Bind(event, boundmethod)
def _append_menu_item(self, menu, wx_id, title, fxn): if wx_id is None: wx_id = wx.NewId() menu.Append(wx_id, title) wx.EVT_MENU(menu, wx_id, fxn) return wx_id
def init_popup_menu(self): self.popup_menu_needs_rebuild = False if self.popup_menu is not None: self.popup_menu.Destroy() menu = wx.Menu() menu.Append(wx.NewId(), 'Cursor mode:').Enable(False) self.cursor_mode_to_eventID = {} cmd_num = 1 for cursor_mode in self.popup_menu_cursor_modes: fxn = self.available_cursor_modes[cursor_mode]['set-to-mode'] wx_id = wx.NewId() menu.AppendCheckItem(wx_id, ' ' + cursor_mode + '\tCtrl+' + str(cmd_num)) wx.EVT_MENU(menu, wx_id, fxn) self.cursor_mode_to_eventID[cursor_mode] = wx_id self.Bind(wx.EVT_MENU, fxn, id=wx_id) self.accelerator_table.append((wx.ACCEL_CMD, ord(str(cmd_num)), wx_id)) cmd_num += 1 menu.AppendSeparator() image_cmap_submenu = wx.Menu() for cmap in self.ztv_frame.available_cmaps: menu_item = image_cmap_submenu.AppendCheckItem(self.cmap_to_eventID[cmap], cmap) wx.EVT_MENU(image_cmap_submenu, self.cmap_to_eventID[cmap], self.on_change_cmap_event) menu_item.SetBitmap(self.cmap_bitmaps[cmap]) menu.AppendMenu(-1, 'Color Maps', image_cmap_submenu) wx_id = wx.NewId() self.menu_item_invert_map = menu.AppendCheckItem(wx_id, 'Invert Color Map') wx.EVT_MENU(menu, wx_id, self.ztv_frame.invert_cmap) self.menu_item_invert_map.Check(self.ztv_frame.is_cmap_inverted) image_scaling_submenu = wx.Menu() for scaling in self.ztv_frame.available_scalings: menu_item = image_scaling_submenu.AppendCheckItem(self.scaling_to_eventID[scaling], scaling) wx.EVT_MENU(image_scaling_submenu, self.scaling_to_eventID[scaling], self.on_change_scaling_event) menu.AppendMenu(-1, 'Scaling', image_scaling_submenu) menu.AppendSeparator() self.popup_menu_cur_fits_header_eventID = wx.NewId() self._append_menu_item(menu, self.popup_menu_cur_fits_header_eventID, 'FITS Header', self.on_display_cur_fits_header) self.popup_menu = menu self.SetAcceleratorTable(wx.AcceleratorTable(self.accelerator_table))
def _InitRecordPaneMenu(self): # make a menu self.record_pane_menu = wx.Menu() # Create IDs # self.record_pane_popup_id1 = wx.NewId() # Create Binds # self.Bind(wx.EVT_MENU, self.RecordPaneMenu_ExtractClick, id=self.record_pane_popup_id1) # Create Items # self.record_pane_menu.Append(self.record_pane_popup_id1, "Extract")
def OnRightDown(self,event): if IsNotWX4(): item = self.mainlist.HitTest(event.GetPosition())[0] else: item = self.mainlist.HitTest(event.GetPoint())[0] if item > -1: menu = wx.Menu() if IsNotWX4(): self.CurrentListItem = event.m_itemIndex else: self.CurrentListItem = event.GetIndex() itemup = wx.MenuItem(menu, wx.ID_UP, "Move up") itemdel = wx.MenuItem(menu, wx.ID_DELETE, "Delete") itemdown = wx.MenuItem(menu, wx.ID_DOWN, "Move Down") if IsNotWX4(): menu.AppendItem(itemup) menu.AppendItem(itemdel) menu.AppendItem(itemdown) else: menu.Append(itemup) menu.Append(itemdel) menu.Append(itemdown) self.Bind(wx.EVT_MENU, self.OnClickUp, itemup) self.Bind(wx.EVT_MENU, self.OnItemDel, itemdel) self.Bind(wx.EVT_MENU, self.OnClickDown, itemdown) if IsNotWX4(): x,y = event.GetPosition() else: x,y = event.GetPoint().Get() mx,my = self.hbox1.GetSize() x= 3*mx/4 self.PopupMenu( menu, (x,y))
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, title): (self.display_length_, self.display_height_) = wx.GetDisplaySize() self.frame_width_ = self.display_length_ * 90 / 100 self.frame_height_ = self.display_height_ * 90 / 100 self.answer_panel_width_ = self.frame_width_ * 15 / 100 super(MainFrame, self).__init__(parent=parent, title=title, size=(self.frame_width_, self.frame_height_)) self.splitter = wx.SplitterWindow(parent=self, style=wx.SP_LIVE_UPDATE) self.splitter.SetMinimumPaneSize(min=100) self.web_panel = WebPanel(parent=self.splitter) self.answer_panel = wx.Panel(parent=self.splitter) self.answers_box = wx.BoxSizer(orient=wx.VERTICAL) self.answers_box.Add(item=self.answer_panel) self.splitter.SplitVertically(window1=self.answer_panel, window2=self.web_panel, sashPosition=self.answer_panel_width_) self.Sizer = wx.BoxSizer(orient=wx.VERTICAL) self.Sizer.Add(item=self.splitter, proportion=CAN_CHANGE, flag=wx.EXPAND) auto_answer_button = wx.Button(parent=self, label=u"????") self.Bind(event=wx.EVT_BUTTON, handler=self.click_search_answer, source=auto_answer_button) self.buttons_box = wx.BoxSizer(orient=wx.HORIZONTAL) self.buttons_box.Add(item=auto_answer_button, proportion=CAN_NOT_CHANGE, flag=wx.LEFT | wx.RIGHT, border=5) self.Sizer.Add(item=self.buttons_box, proportion=CAN_NOT_CHANGE, flag=wx.TOP | wx.BOTTOM, border=5) menu = wx.Menu() menu_about = menu.Append(id=wx.ID_ABOUT, text=u"&??", help=u" ?????") menu_feedback = menu.Append(id=wx.ID_OPEN, text=u"&??", help=u" ??") self.Bind(event=wx.EVT_MENU, handler=self.show_about, source=menu_about) self.Bind(event=wx.EVT_MENU, handler=self.show_feedback, source=menu_feedback) menu_bar = wx.MenuBar() menu_bar.Append(menu, u"&??") self.SetMenuBar(menu_bar) self.statusbar = self.CreateStatusBar() self.Centre()
def __init__(self, title, pos, size): self.threads = [] self.getsession = [] self.MAC='' self.IP='' wx.Frame.__init__(self, None, -1, title, pos, size) menuFile = wx.Menu() menuFile.Append(1, u"&??...",u"?????") menuFile.Append(3,u"&????",u"?????IP") menuFile.AppendSeparator() menuFile.Append(2,u"&Bug Report",u"???????bug?") menuBar = wx.MenuBar() menuBar.Append(menuFile, u"&??") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnAbout,id=1) self.Bind(wx.EVT_MENU,self.OnBugReport,id=2) hosts = self.Bind(wx.EVT_MENU,self.OnSet,id=3) self.CreateStatusBar() self.SetStatusText(u"????") panel = wx.Panel(self) self.connect = wx.Button(panel,label=u"??",pos=(240, 60),size=(80, 50)) self.disconnect = wx.Button(panel,label=u"??",pos=(330,60),size=(80,50)) self.connect.Disable() self.disconnect.Disable() self.Bind(wx.EVT_BUTTON, self.OnDisconnect,self.disconnect) self.Bind(wx.EVT_BUTTON,self.OnConnect,self.connect) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) wx.StaticText(panel, -1, u"???:", pos=(28, 40)) self.username = wx.TextCtrl(panel, -1 ,pos=(80, 40)) self.username.SetInsertionPoint(0) self.Bind(wx.EVT_TEXT,self.Onuser,self.username) wx.StaticText(panel,-1,u"??:",pos=(242,40)) self.pwd = wx.TextCtrl(panel, -1,pos=(280,40),style=wx.TE_PASSWORD |wx.TE_PROCESS_ENTER) self.Bind(wx.EVT_TEXT,self.Onpwd,self.pwd) wx.CheckBox(panel, -1, u"????", (20, 80), (150, 20)) wx.CheckBox(panel, -1, u"????", (110, 80), (150, 20))
def search_menu(self): menu = wx.Menu() menu.Append(wx.ID_ANY, "Recent searches").Enable(False) for item in self.search_recent: self.Bind(wx.EVT_MENU, handler=self.click_recent, source=menu.Append(wx.ID_ANY, item)) return menu
def __init__(self): super(globalPluginHandler.GlobalPlugin, self).__init__() self.ocrSettingsItem = gui.mainFrame.sysTrayIcon.preferencesMenu.Append(wx.ID_ANY, # Translators: The name of the OCR settings item # in the NVDA Preferences menu. _("OCR settings...")) gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onOCRSettings, self.ocrSettingsItem)
def __init__(self): super(GlobalPlugin, self).__init__() # #20: don't even think about proceeding in secure screens (especially add-on updates). if globalVars.appArgs.secure: return self.prefsMenu = gui.mainFrame.sysTrayIcon.preferencesMenu self.w10Settings = self.prefsMenu.Append(wx.ID_ANY, _("&Windows 10 App Essentials..."), _("Windows 10 App Essentials add-on settings")) gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, w10config.onConfigDialog, self.w10Settings) if w10config.canUpdate and config.conf["wintenApps"]["autoUpdateCheck"]: # But not when NVDA itself is updating. if not (globalVars.appArgs.install and globalVars.appArgs.minimal): wx.CallAfter(w10config.autoUpdateCheck)
def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(550, 350)) self.SetBackgroundColour(wx.NamedColour("WHITE")) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.change_plot(0) self.canvas = FigureCanvas(self, -1, self.figure) 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() menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample") menuBar.Append(menu, "&File") 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.AppendItem(item) self.Bind(wx.EVT_MENU, self.OnChangePlot, item) menuBar.Append(menu, "&Functions") self.SetMenuBar(menuBar) self.SetSizer(self.sizer) self.Fit()
def create_menu_item(menu, label, image, func): item = wx.MenuItem(menu, -1, label) item.SetBitmap(img.get(image)) menu.Bind(wx.EVT_MENU, func, id=item.GetId()) menu.Append(item) return item
def create_menu_item(menu, label, image, func): item = wx.MenuItem(menu, -1, label) item.SetBitmap(img.get(image)) menu.Bind(wx.EVT_MENU, func, id=item.GetId()) menu.AppendItem(item) return item
def _init_coll_DisplayMenu_Items(self, parent): AppendMenu(parent, help='', id=wx.ID_REFRESH, kind=wx.ITEM_NORMAL, text=_(u'Refresh') + '\tCTRL+R') if self.EnableDebug: AppendMenu(parent, help='', id=wx.ID_CLEAR, kind=wx.ITEM_NORMAL, text=_(u'Clear Errors') + '\tCTRL+K') parent.AppendSeparator() zoommenu = wx.Menu(title='') parent.AppendMenu(wx.ID_ZOOM_FIT, _("Zoom"), zoommenu) for idx, value in enumerate(ZOOM_FACTORS): new_id = wx.NewId() AppendMenu(zoommenu, help='', id=new_id, kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%") self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id) parent.AppendSeparator() AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE, kind=wx.ITEM_NORMAL, text=_(u'Switch perspective') + '\tF12') self.Bind(wx.EVT_MENU, self.SwitchFullScrMode, id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE) AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE, kind=wx.ITEM_NORMAL, text=_(u'Reset Perspective')) self.Bind(wx.EVT_MENU, self.OnResetPerspective, id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE) self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH) if self.EnableDebug: self.Bind(wx.EVT_MENU, self.OnClearErrorsMenu, id=wx.ID_CLEAR)
def RefreshEditorToolBar(self): selected = self.TabsOpened.GetSelection() menu = None if selected != -1: window = self.TabsOpened.GetPage(selected) if isinstance(window, (Viewer, TextViewer)): if not window.IsDebugging(): menu = self.Controler.GetEditedElementBodyType(window.GetTagName()) else: menu = "debug" if menu is not None and menu != self.CurrentMenu: self.ResetEditorToolBar() self.CurrentMenu = menu self.CurrentEditorToolBar = [] EditorToolBar = self.Panes["EditorToolBar"] if EditorToolBar: for radio, modes, id, method, picture, help in EditorToolBarItems[menu]: if modes & self.DrawingMode: if radio or self.DrawingMode == FREEDRAWING_MODE: EditorToolBar.AddRadioTool(id, GetBitmap(picture), wx.NullBitmap, help) else: EditorToolBar.AddSimpleTool(id, GetBitmap(picture), help) self.Bind(wx.EVT_MENU, getattr(self, method), id=id) self.CurrentEditorToolBar.append(id) EditorToolBar.Realize() self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) self.AUIManager.GetPane("EditorToolBar").Show() self.AUIManager.Update() elif menu is None: self.ResetEditorToolBar() self.CurrentMenu = menu self.ResetCurrentMode() # ------------------------------------------------------------------------------- # EditorToolBar Items Functions # -------------------------------------------------------------------------------
def BuildStdIECTypesMenu(self, type_menu): # build a submenu containing standard IEC types base_menu = wx.Menu(title='') for base_type in self.Controler.GetBaseTypes(): new_id = wx.NewId() base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu)
def BuildUserTypesMenu(self, type_menu): # build a submenu containing user-defined types datatype_menu = wx.Menu(title='') datatypes = self.Controler.GetDataTypes(basetypes=False, confnodetypes=False) for datatype in datatypes: new_id = wx.NewId() datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu)
def BuildLibsTypesMenu(self, type_menu): for category in self.Controler.GetConfNodeDataTypes(): if len(category["list"]) > 0: # build a submenu containing confnode types confnode_datatype_menu = wx.Menu(title='') for datatype in category["list"]: new_id = wx.NewId() confnode_datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) type_menu.AppendMenu(wx.NewId(), category["name"], confnode_datatype_menu)
def BuildProjectTypesMenu(self, type_menu, classtype): # build a submenu containing function block types bodytype = self.Controler.GetEditedElementBodyType(self.TagName) pouname, poutype = self.Controler.GetEditedElementType(self.TagName) if classtype in ["Input", "Output", "InOut", "External", "Global"] or \ poutype != "function" and bodytype in ["ST", "IL"]: functionblock_menu = wx.Menu(title='') fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName) for functionblock_type in fbtypes: new_id = wx.NewId() functionblock_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu)
def BuildArrayTypesMenu(self, type_menu): new_id = wx.NewId() type_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array")) self.Bind(wx.EVT_MENU, self.VariableArrayTypeFunction, id=new_id)
def AddMenuItems(self, menu, items): for item in items: if item is None: menu.AppendSeparator() else: id, kind, text, help, callback = item AppendMenu(menu, help=help, id=id, kind=kind, text=text) # Link menu event to corresponding called functions self.Bind(wx.EVT_MENU, callback, id=id) # Add Block Pin Menu items to the given menu