我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.NewId()。
def reg_hot_keys(self): """ hotkeys: Alt+e, show dialog, also extract tags Alt+a, show dialog, without extracting tags Alt+q, quit the program Esc, minimize the dialog to system tray Enter, add the tags """ self.hotkeys = {'extract_tag': ( wx.NewId(), wx.MOD_ALT, 0x45), # alt+e 'activate': ( wx.NewId(), wx.MOD_ALT, 0x41), # alt+a 'refresh': ( wx.NewId(), wx.MOD_ALT, 0x52), # alt+r 'quit': ( wx.NewId(), wx.MOD_ALT, 0x51), # alt+q } # https://msdn.microsoft.com/en-us/library/windows/desktop/ms646309(v=vs.85).aspx # https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx for _, key in self.hotkeys.items(): # print(_, key) self.RegisterHotKey(*key)
def makeSettings(self, settingsSizer): # Translators: This is the static text of the Quick Profile Wizard dialog. msgIntro=_("Choose which options you want to reset to the default value for the Lambdas profile") self.introStxt=wx.StaticText(self,-1,label=msgIntro) settingsSizer.Add(self.introStxt,flag=wx.BOTTOM) # Translators: This is the label for a checkbox in the # Quick Profile Wizard dialog. self.defaultTranslationTableCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Keep the LAMBDA braille table for the current language (%s)") % TABLE_NAME) self.defaultTranslationTableCheckBox.SetValue(True) settingsSizer.Add(self.defaultTranslationTableCheckBox,border=10,flag=wx.BOTTOM) # Translators: This is the label for a checkbox in the # Quick Profile Wizard dialog. self.brailleTetherToFocusCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Set the braille cursor to tether the focus")) self.brailleTetherToFocusCheckBox.SetValue(True) settingsSizer.Add(self.brailleTetherToFocusCheckBox,border=10,flag=wx.BOTTOM) # Translators: This is the label for a checkbox in the # Quick Profile Wizard dialog. self.disableReadByParagraphCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Disable the Braille reading by paragraph")) self.disableReadByParagraphCheckBox.SetValue(True) settingsSizer.Add(self.disableReadByParagraphCheckBox,border=10,flag=wx.BOTTOM) # Translators: This is the label for a checkbox in the # Quick Profile Wizard dialog. self.disableBrailleWordWrapCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Disable word wrappping of the braille line")) self.disableBrailleWordWrapCheckBox.SetValue(True) settingsSizer.Add(self.disableBrailleWordWrapCheckBox,border=10,flag=wx.BOTTOM)
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_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 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 AddBlockPinMenuItems(self, menu, connector): [ID_NO_MODIFIER, ID_NEGATED, ID_RISING_EDGE, ID_FALLING_EDGE] = [wx.NewId() for i in xrange(4)] # Create menu items self.AddMenuItems(menu, [ (ID_NO_MODIFIER, wx.ITEM_RADIO, _(u'No Modifier'), '', self.OnNoModifierMenu), (ID_NEGATED, wx.ITEM_RADIO, _(u'Negated'), '', self.OnNegatedMenu), (ID_RISING_EDGE, wx.ITEM_RADIO, _(u'Rising Edge'), '', self.OnRisingEdgeMenu), (ID_FALLING_EDGE, wx.ITEM_RADIO, _(u'Falling Edge'), '', self.OnFallingEdgeMenu)]) type = self.Controler.GetEditedElementType(self.TagName, self.Debug) menu.Enable(ID_RISING_EDGE, type != "function") menu.Enable(ID_FALLING_EDGE, type != "function") if connector.IsNegated(): menu.Check(ID_NEGATED, True) elif connector.GetEdge() == "rising": menu.Check(ID_RISING_EDGE, True) elif connector.GetEdge() == "falling": menu.Check(ID_FALLING_EDGE, True) else: menu.Check(ID_NO_MODIFIER, True) # Add Alignment Menu items to the given 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 OnVariablesGridEditorShown(self, event): row, col = event.GetRow(), event.GetCol() if self.Table.GetColLabelValue(col, False) == "Type": type_menu = wx.Menu(title='') 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) datatype_menu = wx.Menu(title='') for datatype in self.Controler.GetDataTypes(): 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) rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize()) type_menu.Destroy() event.Veto() else: event.Skip()
def GetConfNodeMenuItems(self): if self.Editable: add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_SLAVEEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)), (wx.ITEM_NORMAL, (_('SDO Client'), ID_SLAVEEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)), (wx.ITEM_NORMAL, (_('PDO Transmit'), ID_SLAVEEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)), (wx.ITEM_NORMAL, (_('PDO Receive'), ID_SLAVEEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)), (wx.ITEM_NORMAL, (_('Map Variable'), ID_SLAVEEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)), (wx.ITEM_NORMAL, (_('User Type'), ID_SLAVEEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))] profile = self.Controler.GetCurrentProfileName() if profile not in ("None", "DS-301"): other_profile_text = _("%s Profile") % profile add_menu.append((wx.ITEM_SEPARATOR, None)) for text, indexes in self.Manager.GetCurrentSpecificMenu(): add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text)))) else: other_profile_text = _('Other Profile') return [(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, '', self.OnCommunicationMenu)), (wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)), (wx.ITEM_NORMAL, (other_profile_text, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)), (wx.ITEM_SEPARATOR, None), (add_menu, (_('Add'), ID_SLAVEEDITORCONFNODEMENUADD))] return []
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 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 __init__(self, parent, name, number, minnamelen, maxnamelen): wxskinDialog.__init__(self, parent, -1, "Phonebook edit entry") self.SetAutoLayout(True) self.name = None self.number = None nameTextId = wx.NewId() # Main window resizer object border = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, "Enter the phonebook entry name, number and press OK.") border.Add(label, 1, wx.ALL, 10) #fgs = wx.FlexGridSizer(2,3,5,20) fgs = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Name (max %d): " % maxnamelen) fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10) self.nameCtrl = wx.TextCtrl(self, nameTextId, name, validator = pySIMvalidator(None, minnamelen, maxnamelen)) fgs.Add(self.nameCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10) border.Add(fgs, 1, wx.ALL) fgs = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Number (max 20): ") fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10) self.numberCtrl = wx.TextCtrl(self, -1, number, validator = pySIMvalidator("+*#pw0123456789", None, 20)) fgs.Add(self.numberCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10) border.Add(fgs, 1, wx.ALL) buttons = wx.BoxSizer(wx.HORIZONTAL) buttons.Add(wx.Button(self, ID_BUTTON_OK, "Okay"), 1, wx.ALIGN_LEFT | wx.ALL, 20) buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20) border.Add(buttons, 1, wx.ALL) wx.EVT_BUTTON(self, ID_BUTTON_OK, self.onOK) wx.EVT_TEXT_ENTER(self, nameTextId, self.onOK) self.SetAutoLayout(1); self.SetSizer(border) border.Fit(self) self.Layout()
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 _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 OnInit(self): frame = wx.Frame(None, -1, "Hello from wxPython") id=wx.NewId() self.list=wx.ListCtrl(frame,id,style=wx.LC_REPORT|wx.SUNKEN_BORDER) self.list.Show(True) self.list.InsertColumn(0,"Data #1") self.list.InsertColumn(1,"Data #2") self.list.InsertColumn(2,"Data #3") # 0 will insert at the start of the list pos = self.list.InsertStringItem(0,"hello") # add values in the other columns on the same row self.list.SetStringItem(pos,1,"world") self.list.SetStringItem(pos,2,"!") pos = self.list.InsertStringItem(0,"wat") self.list.SetStringItem(pos,1,"um") self.list.SetStringItem(pos,2,"wha") self.itemDataMap = { 0: ("hello","world","!"), 1: ("wat","um","wha") } LCM.ColumnSorterMixin.__init__(self,3) frame.Show(True) self.SetTopWindow(frame) return True
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 OnMessagePanelRightUp(self, event): message = self.GetMessageByScreenPos(*event.GetPosition()) if message is not None: menu = wx.Menu(title='') new_id = wx.NewId() menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Copy")) self.Bind(wx.EVT_MENU, self.GetCopyMessageToClipboardFunction(message), id=new_id) self.MessagePanel.PopupMenu(menu) menu.Destroy() event.Skip()
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 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 OnStructureElementsGridEditorShown(self, event): row, col = event.GetRow(), event.GetCol() if self.StructureElementsTable.GetColLabelValue(col, False) == "Type": type_menu = wx.Menu(title='') base_menu = wx.Menu(title='') for base_type in self.Controler.GetBaseTypes(): new_id = wx.NewId() AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), id=new_id) type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) datatype_menu = wx.Menu(title='') for datatype in self.Controler.GetDataTypes(self.TagName, False): new_id = wx.NewId() AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), id=new_id) type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) new_id = wx.NewId() AppendMenu(type_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array")) self.Bind(wx.EVT_MENU, self.ElementArrayTypeFunction, id=new_id) # functionblock_menu = wx.Menu(title='') # 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"]: # for functionblock_type in self.Controler.GetFunctionBlockTypes(self.TagName): # new_id = wx.NewId() # AppendMenu(functionblock_menu, 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) rect = self.StructureElementsGrid.BlockToDeviceRect((row, col), (row, col)) self.StructureElementsGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.StructureElementsGrid.GetColLabelSize()) type_menu.Destroy() event.Veto() else: event.Skip()
def AddWireMenuItems(self, menu, delete=False, replace=False): [ID_ADD_SEGMENT, ID_DELETE_SEGMENT, ID_REPLACE_WIRE, ] = [wx.NewId() for i in xrange(3)] # Create menu items self.AddMenuItems(menu, [ (ID_ADD_SEGMENT, wx.ITEM_NORMAL, _(u'Add Wire Segment'), '', self.OnAddSegmentMenu), (ID_DELETE_SEGMENT, wx.ITEM_NORMAL, _(u'Delete Wire Segment'), '', self.OnDeleteSegmentMenu), (ID_REPLACE_WIRE, wx.ITEM_NORMAL, _(u'Replace Wire by connections'), '', self.OnReplaceWireMenu)]) menu.Enable(ID_DELETE_SEGMENT, delete) menu.Enable(ID_REPLACE_WIRE, replace) # Add Divergence Menu items to the given menu
def AddDivergenceMenuItems(self, menu, delete=False): [ID_ADD_BRANCH, ID_DELETE_BRANCH] = [wx.NewId() for i in xrange(2)] # Create menu items self.AddMenuItems(menu, [ (ID_ADD_BRANCH, wx.ITEM_NORMAL, _(u'Add Divergence Branch'), '', self.OnAddBranchMenu), (ID_DELETE_BRANCH, wx.ITEM_NORMAL, _(u'Delete Divergence Branch'), '', self.OnDeleteBranchMenu)]) menu.Enable(ID_DELETE_BRANCH, delete) # Add Add Menu items to the given menu
def AddDefaultMenuItems(self, menu, edit=False, block=False): if block: [ID_EDIT_BLOCK, ID_DELETE, ID_ADJUST_BLOCK_SIZE] = [wx.NewId() for i in xrange(3)] # Create menu items self.AddMenuItems(menu, [ (ID_EDIT_BLOCK, wx.ITEM_NORMAL, _(u'Edit Block'), '', self.OnEditBlockMenu), (ID_ADJUST_BLOCK_SIZE, wx.ITEM_NORMAL, _(u'Adjust Block Size'), '', self.OnAdjustBlockSizeMenu), (ID_DELETE, wx.ITEM_NORMAL, _(u'Delete'), '', self.OnDeleteMenu)]) menu.Enable(ID_EDIT_BLOCK, edit) else: [ID_CLEAR_EXEC_ORDER, ID_RESET_EXEC_ORDER] = [wx.NewId() for i in xrange(2)] # Create menu items if self.CurrentLanguage == 'FBD': self.AddMenuItems(menu, [ (ID_CLEAR_EXEC_ORDER, wx.ITEM_NORMAL, _(u'Clear Execution Order'), '', self.OnClearExecutionOrderMenu), (ID_RESET_EXEC_ORDER, wx.ITEM_NORMAL, _(u'Reset Execution Order'), '', self.OnResetExecutionOrderMenu)]) menu.AppendSeparator() add_menu = wx.Menu(title='') self.AddAddMenuItems(add_menu) menu.AppendMenu(-1, _(u'Add'), add_menu) menu.AppendSeparator() [ID_CUT, ID_COPY, ID_PASTE] = [wx.NewId() for i in xrange(3)] # Create menu items self.AddMenuItems(menu, [ (ID_CUT, wx.ITEM_NORMAL, _(u'Cut'), '', self.GetClipboardCallBack(self.Cut)), (ID_COPY, wx.ITEM_NORMAL, _(u'Copy'), '', self.GetClipboardCallBack(self.Copy)), (ID_PASTE, wx.ITEM_NORMAL, _(u'Paste'), '', self.GetAddMenuCallBack(self.Paste))]) menu.Enable(ID_CUT, block) menu.Enable(ID_COPY, block) menu.Enable(ID_PASTE, self.ParentWindow.GetCopyBuffer() is not None)
def PopupConnectionMenu(self): menu = wx.Menu(title='') connection_type = self.SelectedElement.GetType() for type_label, type in [(_("Connector"), CONNECTOR), (_("Continuation"), CONTINUATION)]: new_id = wx.NewId() AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_RADIO, text=type_label) self.Bind(wx.EVT_MENU, self.GetChangeConnectionTypeMenuFunction(type), id=new_id) if type == connection_type: menu.Check(new_id, True) menu.AppendSeparator() self.AddDefaultMenuItems(menu, block=True) self.Editor.PopupMenu(menu) menu.Destroy()
def GetConfNodeMenuItems(self): add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_NETWORKEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)), (wx.ITEM_NORMAL, (_('SDO Client'), ID_NETWORKEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)), (wx.ITEM_NORMAL, (_('PDO Transmit'), ID_NETWORKEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)), (wx.ITEM_NORMAL, (_('PDO Receive'), ID_NETWORKEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)), (wx.ITEM_NORMAL, (_('Map Variable'), ID_NETWORKEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)), (wx.ITEM_NORMAL, (_('User Type'), ID_NETWORKEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))] profile = self.Manager.GetCurrentProfileName() if profile not in ("None", "DS-301"): other_profile_text = _("%s Profile") % profile add_menu.append((wx.ITEM_SEPARATOR, None)) for text, indexes in self.Manager.GetCurrentSpecificMenu(): add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text)))) else: other_profile_text = _('Other Profile') master_menu = [(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_NETWORKEDITORMASTERMENUDS301PROFILE, '', self.OnCommunicationMenu)), (wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_NETWORKEDITORMASTERMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)), (wx.ITEM_NORMAL, (other_profile_text, ID_NETWORKEDITORMASTERMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)), (wx.ITEM_SEPARATOR, None), (add_menu, (_('Add'), ID_NETWORKEDITORMASTERMENUADD))] return [(wx.ITEM_NORMAL, (_('Add slave'), ID_NETWORKEDITORCONFNODEMENUADDSLAVE, '', self.OnAddSlaveMenu)), (wx.ITEM_NORMAL, (_('Remove slave'), ID_NETWORKEDITORCONFNODEMENUREMOVESLAVE, '', self.OnRemoveSlaveMenu)), (wx.ITEM_SEPARATOR, None), (master_menu, (_('Master'), ID_NETWORKEDITORCONFNODEMENUMASTER))]
def buildShortcut(parent): shortcuts = [] for item in list(PluginsManager.plgs.values()): cut = ShotcutManager.get(item.title) if cut!=None: acc, code = codeSplit(cut) if code==-1: continue; nid = wx.NewId() parent.Bind(wx.EVT_MENU, lambda x, p=item:p().start(), id=nid) shortcuts.append((acc, code, nid)) return wx.AcceleratorTable(shortcuts)
def makeSettings(self, settingsSizer): # Translators: label of a checkbox which toggles the announcement of breakpoints via speech self.announceBreakpointCheckBox=wx.CheckBox(self, wx.NewId(), label=_("&Announce breakpoints via speech")) self.announceBreakpointCheckBox.SetValue(config.conf["visualStudio"]["announceBreakpoints"]) settingsSizer.Add(self.announceBreakpointCheckBox,border=10, flag=wx.BOTTOM) # Translators: label of a checkbox which toggles the beep on breakpoints option self.beepOnBreakpointCheckBox=wx.CheckBox(self, wx.NewId(), label=_("&Beep on breakpoints")) self.beepOnBreakpointCheckBox.SetValue(config.conf["visualStudio"]["beepOnBreakpoints"]) settingsSizer.Add(self.beepOnBreakpointCheckBox,border=10, flag=wx.BOTTOM) # Translators: label of a checkbox which toggles reporting of intelliSense menu item position info self.reportIntelliSensePosInfoCheckBox=wx.CheckBox(self, wx.NewId(), label=_("&Report intelliSense menu item position information")) self.reportIntelliSensePosInfoCheckBox.SetValue(config.conf["visualStudio"]["reportIntelliSensePosInfo"]) settingsSizer.Add(self.reportIntelliSensePosInfoCheckBox,border=10, flag=wx.BOTTOM)
def _create_menu(self): """ Creates a menu """ menubar = wx.MenuBar() trainingMenu = wx.Menu() srMenu = wx.Menu() #settMenu = wx.Menu() testsMenu = wx.Menu() self.training_rec_menu_item = trainingMenu.Append(wx.NewId(), "&New", "New") self.max_time_menu_item = trainingMenu.Append(wx.NewId(), "&Edit max time", "Edit max time") self.start_rec_menu_item = srMenu.Append(wx.NewId(), "&Start", "Start") self.partial_time_menu_item = srMenu.Append(wx.NewId(), "&Edit partial time", "Edit partial time") self.sett1 = testsMenu.Append(wx.NewId(), "&Incremental", "Incremental",kind=wx.ITEM_RADIO ) self.sett2 = testsMenu.Append(wx.NewId(), "&Fixed", "Fixed",kind=wx.ITEM_RADIO ) self.sett3 = testsMenu.Append(wx.NewId(), "&One shot", "One shot",kind=wx.ITEM_RADIO ) self.sett2.Enable(True) self.sett3.Enable(True) testsMenu.Check(self.sett1.GetId(), True) testsMenu.Check(self.sett2.GetId(), False) menubar.Append(trainingMenu, '&Training') menubar.Append(srMenu, '&Test') menubar.Append(testsMenu, '&Settings') #menubar.Append(settMenu, '&Settings') self.SetMenuBar(menubar)
def add_type(self, type_name): type_id = wx.NewId() self.id_to_type[type_id] = type_name self.menu.Append(type_id, type_name)
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 on_rightclick(self, event): treeid = event.GetItem() uid, tree_tid = self.GetItemData(treeid) UIM = UIManager() controller = UIM.get(self._controller_uid) OM = ObjectManager(self) if uid is None: # Object attributes return if uid == controller._PSEUDOROOTUID and tree_tid is None: return # self.popup_obj = (uid, tree_tid) self.popupmenu = wx.Menu() if self._is_convertible(uid): item = self.popupmenu.Append(wx.NewId(), 'Convert unit') self.Bind(wx.EVT_MENU, self.OnUnitConvert, item) self.popupmenu.AppendSeparator() # if tree_tid is not None: # Exclude all objects from a class menu_option_str = u'Exclude all objects [{}]'.format(tree_tid) else: # Exclude a specific object obj = OM.get(uid) #classid, oid = uid menu_option_str = u'Exclude object [' menu_option_str = menu_option_str + str(obj.name) + u']' # item = self.popupmenu.Append(wx.NewId(), menu_option_str) self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item) # pos = event.GetPoint() self.PopupMenu(self.popupmenu, pos)
def new_wx_id(self): """ TODO: Traduzir e melhorar isso Um metodo atalho para wx.NewID(), porém mantendo a sequencia dos Ids dentro do UI Manager. P.S.: A sequencia dos Ids no wx.NewId() é perdida quando se chama de diversos modulos. """ ret_val = self.__class__._wx_ID self.__class__._wx_ID += 1 return ret_val
def _bind_conditions(self, inputdesc): for idesc in inputdesc: if 'conditions' in idesc: name1 = idesc['name'] for condition in idesc['conditions']: name2 = condition[0] widget = self.widgets[name2] evt_id = wx.NewId() widget.bind(self._process_event, evt_id) self.eventmap[evt_id] = (name1, condition) #print self.eventmap
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__(self, parent, raw_header_str, caption, pos=wx.DefaultPosition, size=(500,300), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): self.parent = parent wx.Dialog.__init__(self, parent, -1, caption, pos, size, style) x, y = pos if x == -1 and y == -1: self.CenterOnScreen(wx.BOTH) self.cur_selection = (0, 0) self.raw_header_str = raw_header_str self.raw_header_str_lower = raw_header_str.lower() self.text = text = wx.TextCtrl(self, -1, raw_header_str, style=wx.TE_MULTILINE | wx.TE_READONLY) font1 = wx.Font(12, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.FONTWEIGHT_LIGHT, False) self.text.SetFont(font1) self.text.SetInitialSize((600,400)) main_sizer = wx.BoxSizer(wx.VERTICAL) main_sizer.Add(self.text, 1, wx.EXPAND | wx.ALL, border=5) ok = wx.Button(self, wx.ID_OK, "OK") ok.SetDefault() ok.Bind(wx.EVT_BUTTON, self.on_close) buttons_sizer = wx.BoxSizer(wx.HORIZONTAL) self.search = wx.SearchCtrl(self, size=(200, -1), style=wx.TE_PROCESS_ENTER) self.search.ShowSearchButton(True) self.search.ShowCancelButton(True) # TODO: make layout of search & OK button prettier (OK should be right-aligned properly) buttons_sizer.Add(self.search, 0, wx.ALL | wx.EXPAND) buttons_sizer.Add((315, 0), 1, wx.EXPAND) buttons_sizer.Add(ok, 0, wx.ALL) main_sizer.Add(buttons_sizer, 0, wx.ALL, border=4) self.SetSizerAndFit(main_sizer) self.set_cur_selection() self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.on_search, self.search) self.Bind(wx.EVT_TEXT_ENTER, self.on_search, self.search) self.last_search_str = '' self.last_find_index = 0 self.is_dialog_still_open = True self.Bind(wx.EVT_CLOSE, self.on_close) new_id = wx.NewId() self.Bind(wx.EVT_MENU, self.on_cmd_w, id=new_id) self.SetAcceleratorTable(wx.AcceleratorTable([(wx.ACCEL_CMD, ord(str('w')), new_id)]))
def __init__(self, parent, dpi=None, **kwargs): wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.Size(512,512), **kwargs) self.ztv_frame = self.GetTopLevelParent() self.accelerator_table = [] self.center = wx.RealPoint() self.zoom_rect = None self.eventID_to_cmap = {wx.NewId(): x for x in self.ztv_frame.available_cmaps} self.cmap_to_eventID = {self.eventID_to_cmap[x]: x for x in self.eventID_to_cmap} self.eventID_to_scaling = {wx.NewId(): x for x in self.ztv_frame.available_scalings} self.scaling_to_eventID = {self.eventID_to_scaling[x]: x for x in self.eventID_to_scaling} cmap_bitmap_height = 15 cmap_bitmap_width = 100 self.cmap_bitmaps = {} for cmap in self.ztv_frame.available_cmaps: temp = cm.ScalarMappable(cmap=cmap) rgba = temp.to_rgba(np.outer(np.ones(cmap_bitmap_height, dtype=np.uint8), np.arange(cmap_bitmap_width, dtype=np.uint8))) self.cmap_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_bitmap_width, cmap_bitmap_height, np.uint8(np.round(rgba*255))) self.popup_menu_cursor_modes = ['Zoom', 'Pan'] self.available_cursor_modes = {'Zoom':{'set-to-mode':self.set_cursor_to_zoom_mode}, 'Pan':{'set-to-mode':self.set_cursor_to_pan_mode}} self.available_key_presses = {} self.cursor_mode = 'Zoom' self.max_doubleclick_sec = 0.5 # needed to trap 'real' single clicks from the first click of a double click self.popup_menu_needs_rebuild = True self.popup_menu = None self.xlim = [-9e9, 9e9] self.ylim = [-9e9, 9e9] self.figure = Figure(None, dpi) self.axes = self.figure.add_axes([0., 0., 1., 1.]) self.canvas = FigureCanvasWxAgg(self, -1, self.figure) self.Bind(wx.EVT_SIZE, self._onSize) self.axes_widget = AxesWidget(self.figure.gca()) self.axes_widget.connect_event('motion_notify_event', self.on_motion) self.axes_widget.connect_event('figure_leave_event', self.on_cursor_leave) self.axes_widget.connect_event('figure_enter_event', self.on_cursor_enter) self.axes_widget.connect_event('button_press_event', self.on_button_press) self.axes_widget.connect_event('button_release_event', self.on_button_release) self.axes_widget.connect_event('key_press_event', self.on_key_press) wx.EVT_RIGHT_DOWN(self.figure.canvas, self.on_right_down) # supercedes the above button_press_event pub.subscribe(self.redraw_primary_image, 'redraw-image') pub.subscribe(self.reset_zoom_and_center, 'reset-zoom-and-center') pub.subscribe(self.set_zoom_factor, 'set-zoom-factor') pub.subscribe(self.set_xy_center, 'set-xy-center')
def AddAddMenuItems(self, menu): [ID_ADD_BLOCK, ID_ADD_VARIABLE, ID_ADD_CONNECTION, ID_ADD_COMMENT] = [wx.NewId() for i in xrange(4)] # Create menu items self.AddMenuItems(menu, [ (ID_ADD_BLOCK, wx.ITEM_NORMAL, _(u'Block'), '', self.GetAddMenuCallBack(self.AddNewBlock)), (ID_ADD_VARIABLE, wx.ITEM_NORMAL, _(u'Variable'), '', self.GetAddMenuCallBack(self.AddNewVariable)), (ID_ADD_CONNECTION, wx.ITEM_NORMAL, _(u'Connection'), '', self.GetAddMenuCallBack(self.AddNewConnection)), None]) if self.CurrentLanguage != "FBD": [ ID_ADD_POWER_RAIL, ID_ADD_CONTACT, ID_ADD_COIL, ] = [wx.NewId() for i in xrange(3)] # Create menu items self.AddMenuItems(menu, [ (ID_ADD_POWER_RAIL, wx.ITEM_NORMAL, _(u'Power Rail'), '', self.GetAddMenuCallBack(self.AddNewPowerRail)), (ID_ADD_CONTACT, wx.ITEM_NORMAL, _(u'Contact'), '', self.GetAddMenuCallBack(self.AddNewContact))]) if self.CurrentLanguage != "SFC": self.AddMenuItems(menu, [ (ID_ADD_COIL, wx.ITEM_NORMAL, _(u'Coil'), '', self.GetAddMenuCallBack(self.AddNewCoil))]) menu.AppendSeparator() if self.CurrentLanguage == "SFC": [ ID_ADD_INITIAL_STEP, ID_ADD_STEP, ID_ADD_TRANSITION, ID_ADD_ACTION_BLOCK, ID_ADD_DIVERGENCE, ID_ADD_JUMP, ] = [wx.NewId() for i in xrange(6)] # Create menu items self.AddMenuItems(menu, [ (ID_ADD_INITIAL_STEP, wx.ITEM_NORMAL, _(u'Initial Step'), '', self.GetAddMenuCallBack(self.AddNewStep, True)), (ID_ADD_STEP, wx.ITEM_NORMAL, _(u'Step'), '', self.GetAddMenuCallBack(self.AddNewStep)), (ID_ADD_TRANSITION, wx.ITEM_NORMAL, _(u'Transition'), '', self.GetAddMenuCallBack(self.AddNewTransition)), (ID_ADD_ACTION_BLOCK, wx.ITEM_NORMAL, _(u'Action Block'), '', self.GetAddMenuCallBack(self.AddNewActionBlock)), (ID_ADD_DIVERGENCE, wx.ITEM_NORMAL, _(u'Divergence'), '', self.GetAddMenuCallBack(self.AddNewDivergence)), (ID_ADD_JUMP, wx.ITEM_NORMAL, _(u'Jump'), '', self.GetAddMenuCallBack(self.AddNewJump)), None]) self.AddMenuItems(menu, [ (ID_ADD_COMMENT, wx.ITEM_NORMAL, _(u'Comment'), '', self.GetAddMenuCallBack(self.AddNewComment))]) # Add Default Menu items to the given menu
def Set_Context_Menu(self): # Context menu 1 self.Context_Menu = wx.Menu() C_Menu_Undo = wx.MenuItem(self.Context_Menu, wx.NewId(), '&Undo Ctrl+Z') self.Context_Menu.AppendItem(C_Menu_Undo) self.Context_Menu.Bind(wx.EVT_MENU, self.OnUndo, C_Menu_Undo) C_Menu_Undo.Enable(False) C_Menu_Redo = wx.MenuItem(self.Context_Menu, wx.NewId(), '&Redo Ctrl+Y') self.Context_Menu.AppendItem(C_Menu_Redo) self.Context_Menu.Bind(wx.EVT_MENU, self.OnRedo, C_Menu_Redo) C_Menu_Redo .Enable(False) self.Context_Menu.AppendSeparator() C_Menu_Cut = wx.MenuItem(self.Context_Menu, wx.NewId(), 'Cu&t Ctrl+X') self.Context_Menu.AppendItem(C_Menu_Cut) self.Context_Menu.Bind(wx.EVT_MENU, self.OnCut, C_Menu_Cut) C_Menu_Copy= wx.MenuItem(self.Context_Menu, wx.NewId(), '&Copy Ctrl+C') self.Context_Menu.AppendItem(C_Menu_Copy) self.Context_Menu.Bind(wx.EVT_MENU, self.OnCopy, C_Menu_Copy) C_Menu_Paste= wx.MenuItem(self.Context_Menu, wx.NewId(), '&Paste Ctrl+V ') self.Context_Menu.AppendItem(C_Menu_Paste) self.Context_Menu.Bind(wx.EVT_MENU, self.OnPaste, C_Menu_Paste) #C_Menu_Paste.Enable(False) C_Menu_Delete= wx.MenuItem(self.Context_Menu, wx.NewId(), '&Delete') self.Context_Menu.AppendItem(C_Menu_Delete) self.Context_Menu.Bind(wx.EVT_MENU, self.OnDelete, C_Menu_Delete) # End of Context Menu 1 #Menu 2(Add/Remove) self.Context_Menu2 = wx.Menu() self.C_Menu_Add = wx.MenuItem(self.Context_Menu2, 140, '&Add Row \n ') self.Context_Menu2.AppendItem(self.C_Menu_Add) self.Context_Menu2.Bind(wx.EVT_MENU, self.OnAddClick, self.C_Menu_Add) self.C_Menu_Add.Enable(False) self.C_Menu_Remove = wx.MenuItem(self.Context_Menu2, 141, '&Remove Row \n') self.Context_Menu2.AppendItem(self.C_Menu_Remove) self.Context_Menu2.Bind(wx.EVT_MENU, self.OnRemoveClick, self.C_Menu_Remove) self.C_Menu_Remove.Enable(False)
def _create_selected_obj_menus(self, menu): self._ids_functions = {} selected_obj_menus = OrderedDict() UIM = UIManager() tocs = UIM.list('track_object_controller', self._controller_uid) for toc in tocs: if toc.model.selected: obj = toc.get_object() if obj: obj_submenu = wx.Menu() # funcs = FunctionManager.functions_available_for_class(obj.__class__) for f in funcs: #print #print f['name'] #print f['friendly_name'] #print f['function'] #print f['args'] #print f['kwargs'] id_ = wx.NewId() obj_submenu.Append(id_, f['friendly_name']) self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_) self._ids_functions[id_] = (f['function'], (obj)) # obj_submenu.AppendSeparator() id_ = wx.NewId() obj_submenu.Append(id_, 'Remove from track') self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_) self._ids_functions[id_] = (self._remove_object_helper, (toc.uid) ) # obj_submenu.AppendSeparator() id_ = wx.NewId() obj_submenu.Append(id_, 'Delete object') self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_) self._ids_functions[id_] = (self._delete_object_helper, (toc.get_object().uid) ) # selected_obj_menus[obj] = obj_submenu if selected_obj_menus: for obj, obj_submenu in selected_obj_menus.items(): menu.AppendSubMenu(obj_submenu, obj.get_friendly_name()) menu.AppendSeparator()