def __init__(self, parent, title, server): Frame.__init__(self, parent, title=title, size=(500, 400)) global SETTINGS_FRAME SETTINGS_FRAME = self self.server = server self.setup_xmlrpc_server() self.completed = False self.notebook = Notebook(self, style=NB_MULTILINE) file_menu = Menu() self.next_page = file_menu.Append(ID_ANY, '&Next page\tRAWCTRL+TAB', 'Next page') self.prev_page = file_menu.Append(ID_ANY, '&Prev page\tRAWCTRL+SHIFT+TAB', 'Prev page') self.Bind(EVT_MENU, self.OnTab, self.next_page) self.Bind(EVT_MENU, self.OnTab, self.prev_page) exit_item = file_menu.Append(ID_EXIT, '&Exit...', 'Exit Settings Window') self.Bind(EVT_MENU, self.prepare_for_exit, exit_item) menu_bar = MenuBar() menu_bar.Append(file_menu, '&File') self.SetMenuBar(menu_bar) self.fields = [] for top in sorted(settings.SETTINGS.keys()): # pylint: disable=no-member self.make_page(top) self.CenterOnScreen() self.Show() self.Bind(EVT_ON_KILL, self.OnKill) self.Bind(EVT_ON_COMPLETE, self.OnComplete) self.Bind(EVT_CLOSE, self.xmlrpc_kill) self.expiration = threading.Timer(300, self.xmlrpc_kill) self.expiration.start()
def construct_docs_menu(self): """Constructs the docs menu""" docs_menu = Menu() self.help_values_menu_item = docs_menu.Append( NewId(), 'rofi --help', 'Show or hide pertinent rofi --help info', ITEM_CHECK, ) self.help_values_menu_item.Check(True) self.man_values_menu_item = docs_menu.Append( NewId(), 'man rofi', 'Show or hide pertinent man rofi info', ITEM_CHECK) self.man_values_menu_item.Check(True) return docs_menu
def construct_file_menu(self): """Constructs the file menu""" file_menu = Menu() self.open_menu_item = file_menu.Append(ID_OPEN, '&Open File\tCtrl+o') self.refresh_menu_item = file_menu.Append(NewId(), '&Refresh Config\tCtrl+r') self.refresh_menu_item.Enable(False) self.restore_menu_item = file_menu.Append(NewId(), 'Restore Backup Config') self.restore_menu_item.Enable(False) self.save_as_menu_item = file_menu.Append(ID_SAVEAS, 'Save As\tCtrl+Shift+s') self.save_menu_item = file_menu.Append(ID_SAVE, '&Save\tCtrl+s') self.exit_menu_item = file_menu.Append(ID_EXIT, 'E&xit\tCtrl+w') self.Append(file_menu, '&File')
def construct_rofi_menu(self): """Creates the Rofi menu""" rofi_menu = Menu() self.launch_menu_item = rofi_menu.Append(NewId(), '&Launch Modi\tCtrl+t', 'Launch any available modi') self.Append(rofi_menu, '&Rofi')
def append_menu_items(self, menu: wx.Menu, default: Enum): for name, value in self.__names_and_values: self.__menu_items[value] = menu.Append(wx.ID_ANY, name, kind=wx.ITEM_RADIO) if value == default: self.__menu_items[value].Check(True)
def __makeSubMenuEntry(self, subMenu: Menu, wxId: int, pluginName: str, callback: Callable) -> Menu: subMenu.Append(wxId, pluginName) self._containingFrame.Bind(EVT_MENU, callback, id=wxId) return subMenu
def create_menu_item( parent: wx.Window, menu: wx.Menu, text: str, tooltip: str = '', icon_image: Optional[Image.Image] = None, id: int = wx.ID_ANY, callback: Optional[Callable] = None, ): """Create menu item The tooltip is actually not visible, menu items with tooltips are not supported by WxWidgets. """ menu_item = wx.MenuItem(menu, id, text, helpString=tooltip) if icon_image: bitmap = image_to_bitmap(icon_image) menu_item.SetBitmap(bitmap) menu.Append(menu_item) if callback: parent.Bind(wx.EVT_MENU, partial(on_menu_item, callback=callback), id=id) else: menu_item.Enable(False) return menu_item
def __init__(self, parent, title): Frame.__init__(self, parent, title=title, size=(500, 400)) self.setup_xmlrpc_server() self.completed = False # Create the notebook self.notebook = Notebook(self, style=NB_MULTILINE) # Setting up the menu file_menu = Menu() exit_item = file_menu.Append(ID_EXIT, '&Exit...', 'Exit Settings Window') self.Bind(EVT_MENU, self.prepare_for_exit, exit_item) menu_bar = MenuBar() menu_bar.Append(file_menu, '&File') self.SetMenuBar(menu_bar) alpha = settings.SETTINGS.keys() alpha.sort() self.fields = [] for top in alpha: self.make_page(top) self.CenterOnScreen() self.Show() self.Bind(EVT_CLOSE, self.xmlrpc_kill) def start_server(): while not self.server_quit: self.server.handle_request() Timer(0.5, start_server).start() Timer(300, self.xmlrpc_kill).start()
def create_menubar(self, language_list, style=0): modifier = 'Ctrl' if name == 'nt' else 'Opt' menubar = MenuBar() menubar_file = Menu() menubar_file.Append(ID_FILE_EXPORT, '&Export\t' + modifier + 'E') menubar_file.AppendSeparator() menubar_file.Append(ID_FILE_EXIT, 'E&xit\t' + modifier + 'W') menubar_edit = Menu() menubar_edit_timer = Menu() menubar_edit.AppendSubMenu(menubar_edit_timer, '&Timer') menubar_edit_timer.Append(ID_EDIT_TIMER_START, '&Start\t' + modifier + 'S') menubar_edit_timer.Append(ID_EDIT_TIMER_PAUSE, '&Pause\t' + modifier + 'P') menubar_edit_timer.Append(ID_EDIT_TIMER_RESET, '&Reset\t' + modifier + 'R') menubar_edit_time_stamp = Menu() menubar_edit.AppendSubMenu(menubar_edit_time_stamp, 'Time &Stamp') menubar_edit_time_stamp.Append(ID_EDIT_TIME_STAMP_NEW, '&New\t' + modifier + 'N') menubar_view = Menu() menubar_view.AppendCheckItem(ID_VIEW_SHOW_PREVIEW, 'Show &Preview\t' + modifier + 'Shift+P') menubar_view_language = Menu() language_menu_item_list = [] if language_list is not None: menubar_view_language.Bind(EVT_MENU, lambda x: self.change_language()) menubar_view.AppendSubMenu(menubar_view_language, '&Language') for n in range(len(language_list)): language_menu_item_list.append( menubar_view_language.AppendRadioItem( ID_ANY, language_list[n]['Language Setting'])) menubar_help = Menu() menubar_help.Append(ID_HELP_WELCOME, '&Welcome\t' + modifier + 'Shift+H') menubar_help.AppendSeparator() menubar_help.Append(ID_HELP_VISIT_GITHUB, 'Visit &Github') menubar_help.AppendSeparator() menubar_help.Append(ID_HELP_ABOUT, '&About') menubar.Append(menubar_file, '&File') menubar.Append(menubar_edit, '&Edit') menubar.Append(menubar_view, '&View') menubar.Append(menubar_help, '&Help') return menubar, language_menu_item_list
def register_menu(self, menu: wx.Menu): def _get_callback(plugin): return lambda _: self.callbacks[plugin]() sorted_plugins = sorted(self.plugins, key=lambda p: p.metadata.name) for plugin in sorted_plugins: item = menu.Append(wx.ID_ANY, plugin.metadata.name) menu.Bind(wx.EVT_MENU, _get_callback(plugin), item)
def construct_prefs_menu(self): """Creates the preferences menu""" prefs_menu = Menu() self.backup_on_menu_item = prefs_menu.Append( NewId(), 'Backup pre save', 'Backs up the existing config before saving', ITEM_CHECK) self.backup_on_menu_item.Check(True) prefs_menu.AppendSubMenu(self.construct_docs_menu(), '&Docs') self.Append(prefs_menu, '&Preferences')
def config_menu(self): '''Here we configure the main windows menu''' menu_bar = MenuBar() file_menu = Menu() self.file_item = file_menu.Append(wx.ID_EXIT, 'Quit', 'Quit application') menu_bar.Append(file_menu, '&File') self.SetMenuBar(menu_bar) self.Bind(wx.EVT_MENU, self.OnQuit, self.file_item)
def register_menu(self, menu: wx.Menu, parent: wx.Window): commands = [cast(CommandPlugin, p) for p in self.plugins if p.ptype == PluginType.COMMAND] windowed = [cast(WindowedPlugin, p) for p in self.plugins if p.ptype == PluginType.WINDOWED] if len(self.plugins) != 0: menu.AppendSeparator() for plugin in commands: id_ = wx.NewIdRef(count=1) item = menu.Append(id_, plugin.metadata.name) menu.Bind(wx.EVT_MENU, self.make_command_callback(plugin), item) if len(commands) != 0 and len(windowed) != 0: menu.AppendSeparator() for plugin in windowed: id_ = wx.NewIdRef(count=1) item = menu.Append(id_, plugin.metadata.name) menu.Bind(wx.EVT_MENU, self.make_windowed_callback(plugin, parent), item)
def _initializeAddHierarchySubMenu(self, mnuEdit: Menu) -> Menu: sub: Menu = Menu() sub.Append(SharedIdentifiers.ID_MNU_ADD_PYUT_HIERARCHY, _("&Pyut"), _("Add the UML Diagram of Pyut")) sub.Append(SharedIdentifiers.ID_MNU_ADD_OGL_HIERARCHY, _("&Ogl"), _("Add the UML Diagram of Pyut - Ogl")) mnuEdit.Append(NewIdRef(), _('Add Hierarchy'), sub) return mnuEdit
def __init__(self, parent, ID, title): Frame.__init__(self, parent, ID, title, DefaultPosition, Size(300, 200)) menu = Menu() menu.Append(ID_EXIT, "E&xit", "Terminate the program") menuBar = MenuBar() menuBar.Append(menu, "&File") self.SetMenuBar(menuBar) EVT_MENU(self, ID_EXIT, self.DoExit) # make sure reactor.stop() is used to stop event loop: EVT_CLOSE(self, lambda evt: reactor.stop())
def _initializeErrorViewSubMenu(self, mnuEdit: Menu) -> Menu: sub: Menu = Menu() sub.Append(SharedIdentifiers.ID_MENU_GRAPHIC_ERROR_VIEW, '&Graphic Error View', 'Test graphical error view') sub.Append(SharedIdentifiers.ID_MENU_TEXT_ERROR_VIEW, '&Text Error View', 'Test text error view') sub.Append(SharedIdentifiers.ID_MENU_RAISE_ERROR_VIEW, '&Exception Error View', 'Test raising exception') mnuEdit.Append(NewIdRef(), _('Show Error View'), sub) return mnuEdit
def ShowTreeItemMenu(self, event): hosts = self.hostsTree.GetItemData(event.GetItem()) if not hosts: return self.__currentSelectHost = hosts menu = Menu() popMenuActive = menu.Append(TrayIcon.ID_TREE_MENU_SET_ACTIVE, "设置为当前Hosts") if hosts["id"] == ID_SYSTEM_HOSTS or hosts['alwaysApply']: popMenuActive.Enable(False) else: popMenuActive.Enable(not hosts["active"]) menu.AppendSeparator() popMenuEdit = menu.Append(TrayIcon.ID_TREE_MENU_EDIT, "编辑") popMenuEdit.Enable(hosts["id"] != ID_SYSTEM_HOSTS) popMenuDelete = menu.Append(TrayIcon.ID_TREE_MENU_DELETE, "删除") popMenuDelete.Enable(hosts["id"] != ID_SYSTEM_HOSTS) # menu.Append(TrayIcon.ID_TREE_MENU_REFRESH, "刷新") self.hostsTree.PopupMenu(menu, event.GetPoint()) self.hostsTree.Bind(EVT_MENU, self.OnMenuClicked)
def AddMenuItem(self, menu: wx.Menu, text: str, help_text: str, callback: Callable, entries: List, key: Tuple[Any, wx.KeyCode] = None, id_: str = None): if id_ is None: id_ = wx.NewIdRef(count=1) shortcut = '' if key is not None: entry = wx.AcceleratorEntry(key[0], key[1], id_) entries.append(entry) shortcut = entry.ToString() item = menu.Append(id_, '{}\t{}'.format(text, shortcut), help_text) self.Bind(wx.EVT_MENU, callback, item) self.menu_events.append((callback, item))
def AddToMenu(self, menu: wx.Menu) -> None: menu.Append( wx.MenuItem(menu, self.id_, self.GetMenuItemLabel(), self.longDescription_))
class MenuCreator: def __init__(self, frame: Frame, lastOpenFilesID): from org.pyut.plugins.PluginManager import PluginManager # Plugin Manager should not be in plugins directory self._containingFrame: Frame = frame self.lastOpenedFilesID = lastOpenFilesID self.logger: Logger = getLogger(__name__) self._prefs: PyutPreferences = PyutPreferences() self.plugMgr: PluginManager = PluginManager() self._plugins: PluginMap = PluginMap({}) # To store the plugins self._toolboxIds: ToolboxIdMap = ToolboxIdMap( {}) # Dictionary id --> toolbox @property def fileMenu(self) -> Menu: raise UnsupportedOperation('Property is write only') @fileMenu.setter def fileMenu(self, fileMenu: Menu): self._fileMenu = fileMenu @property def editMenu(self) -> Menu: raise UnsupportedOperation('Property is write only') @editMenu.setter def editMenu(self, editMenu: Menu): self._editMenu = editMenu @property def toolsMenu(self) -> Menu: raise UnsupportedOperation('Property is write only') @toolsMenu.setter def toolsMenu(self, toolsMenu: Menu): self._toolsMenu: Menu = toolsMenu @property def helpMenu(self): raise UnsupportedOperation('Property is write only') @helpMenu.setter def helpMenu(self, helpMenu: Menu): self._helpMenu = helpMenu @property def toolPlugins(self) -> PluginMap: raise UnsupportedOperation('Property is write only') @toolPlugins.setter def toolPlugins(self, toolPlugins: PluginMap): self._toolPlugins = toolPlugins @property def exportPlugins(self) -> PluginMap: raise UnsupportedOperation('Property is write only') @exportPlugins.setter def exportPlugins(self, exportPlugins: PluginMap): self._exportPlugins = exportPlugins @property def importPlugins(self) -> PluginMap: raise UnsupportedOperation('Property is write only') @importPlugins.setter def importPlugins(self, importPlugins: PluginMap): self._importPlugins = importPlugins @property def toolboxIds(self) -> ToolboxIdMap: raise UnsupportedOperation('Property is write only') @toolboxIds.setter def toolboxIds(self, theNewValues: ToolboxIdMap): self._toolboxIds = theNewValues @property def fileMenuHandler(self) -> FileMenuHandler: raise UnsupportedOperation('Property is write only') @fileMenuHandler.setter def fileMenuHandler(self, fileMenuHandler: FileMenuHandler): self._fileMenuHandler = fileMenuHandler @property def editMenuHandler(self) -> EditMenuHandler: raise UnsupportedOperation('Property is write only') @editMenuHandler.setter def editMenuHandler(self, editMenuHandler: EditMenuHandler): self._editMenuHandler = editMenuHandler @property def toolsMenuHandler(self) -> ToolsMenuHandler: raise UnsupportedOperation('Property is write only') @toolsMenuHandler.setter def toolsMenuHandler(self, toolsMenuHandler: ToolsMenuHandler): self._toolsMenuHandler = toolsMenuHandler @property def helpMenuHandler(self) -> HelpMenuHandler: raise UnsupportedOperation('Property is write only') @helpMenuHandler.setter def helpMenuHandler(self, helpMenuHandler: HelpMenuHandler): self._helpMenuHandler = helpMenuHandler def initializeMenus(self): self._initializeFileMenu() self._initializeEditMenu() # ----------------- # Tools menu # ----------------- # mnuTools = Menu() sub = self._makeToolsMenu() if sub is not None: self._toolsMenu.AppendSubMenu(sub, _("Tools"), _('Tools are here')) sub = self._makeToolboxesMenu() if sub is not None: self._toolsMenu.AppendSubMenu(sub, _("Toolboxes"), _('Toolboxes are here')) # Plugins identified self._fileMenuHandler.importPlugins = self._importPlugins self._fileMenuHandler.exportPlugins = self._exportPlugins self._initializeHelpMenu() mnuBar = MenuBar() mnuBar.Append(self._fileMenu, _("&File")) mnuBar.Append(self._editMenu, _("&Edit")) mnuBar.Append(self._toolsMenu, _("&Tools")) mnuBar.Append(self._helpMenu, _("&Help")) containingFrame: Frame = self._containingFrame containingFrame.SetMenuBar(mnuBar) self._fileMenuHandler.setLastOpenedFilesItems() self._bindFileMenuHandlers(containingFrame, self._fileMenuHandler) self._bindEditMenuHandlers(containingFrame, self._editMenuHandler) self._bindHelpMenuHandlers(containingFrame, self._helpMenuHandler) def _initializeFileMenu(self): fileMenu: Menu = self._fileMenu self.mnuFileNew = Menu() self.mnuFileNew.Append(SharedIdentifiers.ID_MNUFILENEWPROJECT, _("&New project\tCtrl-N"), _("New project")) self.mnuFileNew.Append(SharedIdentifiers.ID_MNU_FILE_NEW_CLASS_DIAGRAM, _("New c&lass diagram\tCtrl-L"), _("New class diagram")) self.mnuFileNew.Append( SharedIdentifiers.ID_MNU_FILE_NEW_SEQUENCE_DIAGRAM, _("New s&equence diagram\tCtrl-E"), _("New sequence diagram")) self.mnuFileNew.Append( SharedIdentifiers.ID_MNU_FILE_NEW_USECASE_DIAGRAM, _("New &use-case diagram\tCtrl-U"), _("New use-case diagram")) fileMenu.Append(NewIdRef(), _("&New"), self.mnuFileNew) fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_INSERT_PROJECT, _("&Insert a project...\t"), _("Insert a project in the current project...")) fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_OPEN, _("&Open...\tCtrl-O"), _("Open a file...")) fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_SAVE, _("&Save\tCtrl-S"), _("Save current data")) fileMenu.Append(SharedIdentifiers.ID_MNUFILESAVEAS, _("Save &As...\tCtrl-A"), _("Save current data")) fileMenu.Append(SharedIdentifiers.ID_MNU_PROJECT_CLOSE, _("&Close project\tCtrl-W"), _("Close current project")) fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_REMOVE_DOCUMENT, _("&Remove document"), _("Remove the document from the project")) fileMenu.AppendSeparator() fileMenuHandler: FileMenuHandler = self._fileMenuHandler sub = self._makeExportMenu(fileMenuHandler=fileMenuHandler) if sub is None: sub = Menu() if sub is not None: self._fileMenu.Append(NewIdRef(), _("Export"), sub) sub = self._makeImportMenu(fileMenuHandler=fileMenuHandler) if sub is not None: self._fileMenu.Append(NewIdRef(), _("Import"), sub) fileMenu.AppendSeparator() fileMenu.Append(ID_PREFERENCES, _("P&references"), _("PyUt preferences")) # fileMenu.Append(ID_MNU_FILE_DIAGRAM_PROPERTIES,_("&Diagram Properties"), _("Diagram properties")) fileMenu.AppendSeparator() fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT_SETUP, _("Print se&tup..."), _("Display the print setup dialog box")) fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT_PREVIEW, _("Print pre&view"), _("Diagram preview before printing")) fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT, _("&Print\tCtrl-P"), _("Print the current diagram")) fileMenu.AppendSeparator() sub = self._makeRecentlyOpenedMenu() fileMenu.Append(NewIdRef(), _('Recently Opened'), sub) fileMenu.AppendSeparator() fileMenu.Append(ID_EXIT, _("E&xit"), _("Exit PyUt")) def _initializeEditMenu(self): mnuEdit: Menu = self._editMenu mnuEdit.Append(SharedIdentifiers.ID_MNU_UNDO, _("&Undo\tCtrl-Z"), _("Undo the last performed action")) mnuEdit.Append(SharedIdentifiers.ID_MNU_REDO, _("&Redo\tCtrl-Y"), _("Redo the last undone action")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_CUT, _("Cu&t\tCtrl-X"), _("Cut selected data")) mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_COPY, _("&Copy\tCtrl-C"), _("Copy selected data")) mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_PASTE, _("&Paste\tCtrl-V"), _("Paste selected data")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_SELECT_ALL, _("&Select all"), _("Select all elements")) mnuEdit.AppendSeparator() mnuEdit = self._initializeAddHierarchySubMenu(mnuEdit) if self._prefs.debugErrorViews is True: mnuEdit.AppendSeparator() # noinspection PyUnusedLocal mnuEdit = self._initializeErrorViewSubMenu(mnuEdit) def _initializeHelpMenu(self): mnuHelp = self._helpMenu mnuHelp.Append(ID_ABOUT, _("&About PyUt..."), _("Display the About PyUt dialog box")) mnuHelp.AppendSeparator() mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_INDEX, _("&Index"), _("Display help index")) mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_VERSION, _("Check for newer versions"), _("Check if a newer version of Pyut exists")) mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_WEB, _("&Web site"), _("Open PyUt web site")) mnuHelp.AppendSeparator() mnuHelp.Append(SharedIdentifiers.ID_DEBUG, _("&Debug"), _("Open IPython shell")) def _initializeErrorViewSubMenu(self, mnuEdit: Menu) -> Menu: sub: Menu = Menu() sub.Append(SharedIdentifiers.ID_MENU_GRAPHIC_ERROR_VIEW, '&Graphic Error View', 'Test graphical error view') sub.Append(SharedIdentifiers.ID_MENU_TEXT_ERROR_VIEW, '&Text Error View', 'Test text error view') sub.Append(SharedIdentifiers.ID_MENU_RAISE_ERROR_VIEW, '&Exception Error View', 'Test raising exception') mnuEdit.Append(NewIdRef(), _('Show Error View'), sub) return mnuEdit def _initializeAddHierarchySubMenu(self, mnuEdit: Menu) -> Menu: sub: Menu = Menu() sub.Append(SharedIdentifiers.ID_MNU_ADD_PYUT_HIERARCHY, _("&Pyut"), _("Add the UML Diagram of Pyut")) sub.Append(SharedIdentifiers.ID_MNU_ADD_OGL_HIERARCHY, _("&Ogl"), _("Add the UML Diagram of Pyut - Ogl")) mnuEdit.Append(NewIdRef(), _('Add Hierarchy'), sub) return mnuEdit def _makeRecentlyOpenedMenu(self): sub: Menu = Menu() index = 0 for index in range(index, self._prefs.getNbLOF()): # self.fileMenu.Append(self.lastOpenedFilesID[index], "&" + str(index + 1) + " -") lofAgain: str = f"&{str(index + 1)} -" sub.Append(self.lastOpenedFilesID[index], lofAgain) return sub def _makeExportMenu(self, fileMenuHandler: FileMenuHandler): """ Make the export submenu. """ pluginMap: PluginMap = self._exportPlugins sub: Menu = Menu() for wxId in pluginMap: clazz: type = pluginMap[wxId] pluginInstance: PyutIoPlugin = clazz(None, None) pluginName: str = pluginInstance.getOutputFormat()[0] sub = self.__makeSubMenuEntry(subMenu=sub, wxId=wxId, pluginName=pluginName, callback=fileMenuHandler.onExport) # sub.Append(wxId, pluginName) # self._containingFrame.Bind(EVT_MENU, fileMenuHandler.onExport, id=wxId) return sub def _makeImportMenu(self, fileMenuHandler: FileMenuHandler): """ Make the import submenu. """ pluginMap: PluginMap = self._importPlugins sub: Menu = Menu() for wxId in pluginMap: clazz: type = pluginMap[wxId] pluginInstance: PyutIoPlugin = clazz(None, None) pluginName: str = pluginInstance.getInputFormat()[0] # sub.Append(wxId, pluginName) # self._containingFrame.Bind(EVT_MENU, fileMenuHandler.onImport, id=wxId) sub = self.__makeSubMenuEntry(subMenu=sub, wxId=wxId, pluginName=pluginName, callback=fileMenuHandler.onImport) return sub def _makeToolsMenu(self): """ Make the Tools submenu. """ pluginMap: PluginMap = self._toolPlugins sub: Menu = Menu() for wxId in pluginMap: clazz: type = pluginMap[wxId] pluginInstance: PyutToPlugin = clazz(None, None) sub.Append(wxId, pluginInstance.getMenuTitle()) self._containingFrame.Bind(EVT_MENU, self._toolsMenuHandler.onToolPlugin, id=wxId) return sub def _makeToolboxesMenu(self): """ Make the Toolboxes submenu. """ mediator: Mediator = Mediator() # Get categories categories = mediator.getToolboxesCategories() nb = len(categories) if nb == 0: return None sub: Menu = Menu() for category in categories: categoryId = self.__getWxId(category) sub.Append(categoryId, category) self._containingFrame.Bind( EVT_MENU, self._toolsMenuHandler.onToolboxMenuClick, id=categoryId) return sub def _bindFileMenuHandlers(self, containingFrame: Frame, fileMenuHandler: FileMenuHandler): containingFrame.Bind(EVT_MENU, fileMenuHandler.onNewProject, id=SharedIdentifiers.ID_MNUFILENEWPROJECT) containingFrame.Bind( EVT_MENU, fileMenuHandler.onNewClassDiagram, id=SharedIdentifiers.ID_MNU_FILE_NEW_CLASS_DIAGRAM) containingFrame.Bind( EVT_MENU, fileMenuHandler.onNewSequenceDiagram, id=SharedIdentifiers.ID_MNU_FILE_NEW_SEQUENCE_DIAGRAM) containingFrame.Bind( EVT_MENU, fileMenuHandler.onNewUsecaseDiagram, id=SharedIdentifiers.ID_MNU_FILE_NEW_USECASE_DIAGRAM) containingFrame.Bind(EVT_MENU, fileMenuHandler.onFileInsertProject, id=SharedIdentifiers.ID_MNU_FILE_INSERT_PROJECT) containingFrame.Bind(EVT_MENU, fileMenuHandler.onFileOpen, id=SharedIdentifiers.ID_MNU_FILE_OPEN) containingFrame.Bind(EVT_MENU, fileMenuHandler.onFileSave, id=SharedIdentifiers.ID_MNU_FILE_SAVE) containingFrame.Bind(EVT_MENU, fileMenuHandler.onFileSaveAs, id=SharedIdentifiers.ID_MNUFILESAVEAS) containingFrame.Bind(EVT_MENU, fileMenuHandler.onFileClose, id=SharedIdentifiers.ID_MNU_PROJECT_CLOSE) containingFrame.Bind(EVT_MENU, fileMenuHandler.onRemoveDocument, id=SharedIdentifiers.ID_MNU_FILE_REMOVE_DOCUMENT) containingFrame.Bind(EVT_MENU, fileMenuHandler.onPrintSetup, id=SharedIdentifiers.ID_MNU_FILE_PRINT_SETUP) containingFrame.Bind(EVT_MENU, fileMenuHandler.onPrintPreview, id=SharedIdentifiers.ID_MNU_FILE_PRINT_PREVIEW) containingFrame.Bind(EVT_MENU, fileMenuHandler.onPrint, id=SharedIdentifiers.ID_MNU_FILE_PRINT) # EVT_MENU(self, ID_MNU_FILE_DIAGRAM_PROPERTIES,self._OnMnuFileDiagramProperties) for index in range(self._prefs.getNbLOF()): containingFrame.Bind(EVT_MENU, fileMenuHandler.onRecentlyOpenedFile, id=self.lastOpenedFilesID[index]) containingFrame.Bind(EVT_MENU, fileMenuHandler.onPyutPreferences, id=ID_PREFERENCES) containingFrame.Bind(EVT_MENU, fileMenuHandler.onExit, id=ID_EXIT) def _bindEditMenuHandlers(self, containingFrame: Frame, editMenuHandler: EditMenuHandler): containingFrame.Bind(EVT_MENU, editMenuHandler.onUndo, id=SharedIdentifiers.ID_MNU_UNDO) containingFrame.Bind(EVT_MENU, editMenuHandler.onRedo, id=SharedIdentifiers.ID_MNU_REDO) containingFrame.Bind(EVT_MENU, editMenuHandler.onCut, id=SharedIdentifiers.ID_MNU_EDIT_CUT) containingFrame.Bind(EVT_MENU, editMenuHandler.onCopy, id=SharedIdentifiers.ID_MNU_EDIT_COPY) containingFrame.Bind(EVT_MENU, editMenuHandler.onPaste, id=SharedIdentifiers.ID_MNU_EDIT_PASTE) containingFrame.Bind(EVT_MENU, editMenuHandler.onAddPyut, id=SharedIdentifiers.ID_MNU_ADD_PYUT_HIERARCHY) containingFrame.Bind(EVT_MENU, editMenuHandler.onAddOgl, id=SharedIdentifiers.ID_MNU_ADD_OGL_HIERARCHY) containingFrame.Bind(EVT_MENU, editMenuHandler.onSelectAll, id=SharedIdentifiers.ID_MNU_EDIT_SELECT_ALL) if self._prefs.debugErrorViews is True: from org.pyut.experimental.DebugErrorViews import DebugErrorViews containingFrame.Bind( EVT_MENU, DebugErrorViews.debugGraphicErrorView, id=SharedIdentifiers.ID_MENU_GRAPHIC_ERROR_VIEW) containingFrame.Bind(EVT_MENU, DebugErrorViews.debugTextErrorView, id=SharedIdentifiers.ID_MENU_TEXT_ERROR_VIEW) containingFrame.Bind(EVT_MENU, DebugErrorViews.debugRaiseErrorView, id=SharedIdentifiers.ID_MENU_RAISE_ERROR_VIEW) def _bindHelpMenuHandlers(self, containingFrame: Frame, helpMenuHandler: HelpMenuHandler): containingFrame.Bind(EVT_MENU, helpMenuHandler.onAbout, id=ID_ABOUT) containingFrame.Bind(EVT_MENU, helpMenuHandler.onHelpIndex, id=SharedIdentifiers.ID_MNU_HELP_INDEX) containingFrame.Bind(EVT_MENU, helpMenuHandler.onHelpVersion, id=SharedIdentifiers.ID_MNU_HELP_VERSION) containingFrame.Bind(EVT_MENU, helpMenuHandler.onHelpWeb, id=SharedIdentifiers.ID_MNU_HELP_WEB) containingFrame.Bind(EVT_MENU, helpMenuHandler.onDebug, id=SharedIdentifiers.ID_DEBUG) def __makeSubMenuEntry(self, subMenu: Menu, wxId: int, pluginName: str, callback: Callable) -> Menu: subMenu.Append(wxId, pluginName) self._containingFrame.Bind(EVT_MENU, callback, id=wxId) return subMenu def __getWxId(self, categoryName: str): for key, value in self._toolboxIds.items(): if categoryName == value: return key raise InvalidCategoryException(f'{categoryName} does not exist')
def add_item(menu: wx.Menu, menu_name, callback): id_ = menu.Append(-1, menu_name).Id menu.Bind(wx.EVT_MENU, lambda _: callback(), id=id_)
def __init__(self, logging = False, logFile = None, ): super(SaveMonitor, self).__init__(None, title = "Game Save Monitor" ) menuBar = MenuBar() fileMenu = Menu() addItem = fileMenu.Append(ID_NEW, "&Add", "Add save data backup settings" ) self.Bind(EVT_MENU, self._on_add, addItem) menuBar.Append(fileMenu, "&File") self.showMenu = Menu() menuBar.Append(self.showMenu, "&Show") debugMenu = Menu() menuBar.Append(debugMenu, "&Debug") self._logging = None self.loggingItem = debugMenu.Append(ID_FILE, "&Logging", "Save program output to file", ITEM_CHECK ) self.Bind(EVT_MENU, self._on_log, self.loggingItem) aboutMenu = Menu() aboutItem = aboutMenu.Append(ID_ABOUT, "&About", "Information about this program" ) self.Bind(EVT_MENU, self._on_about, aboutItem) menuBar.Append(aboutMenu, "&About") self.SetMenuBar(menuBar) self.root2threads = {} self.settings = [] self.mainSizer = mainSizer = BoxSizer(VERTICAL) mainSizer.SetSizeHints(self) self.SetSizer(mainSizer) self.Bind(EVT_CLOSE, self._on_close, self) self._logFile = logFile if logFile is None: stream = NullStream() else: try: stream = open(logFile, "a+") except: print_exc() print("Cannot log to %s" % logFile) stream = NullStream() self._logStream = stream self.logging = logging
class SaveMonitor(Frame): def __init__(self, logging = False, logFile = None, ): super(SaveMonitor, self).__init__(None, title = "Game Save Monitor" ) menuBar = MenuBar() fileMenu = Menu() addItem = fileMenu.Append(ID_NEW, "&Add", "Add save data backup settings" ) self.Bind(EVT_MENU, self._on_add, addItem) menuBar.Append(fileMenu, "&File") self.showMenu = Menu() menuBar.Append(self.showMenu, "&Show") debugMenu = Menu() menuBar.Append(debugMenu, "&Debug") self._logging = None self.loggingItem = debugMenu.Append(ID_FILE, "&Logging", "Save program output to file", ITEM_CHECK ) self.Bind(EVT_MENU, self._on_log, self.loggingItem) aboutMenu = Menu() aboutItem = aboutMenu.Append(ID_ABOUT, "&About", "Information about this program" ) self.Bind(EVT_MENU, self._on_about, aboutItem) menuBar.Append(aboutMenu, "&About") self.SetMenuBar(menuBar) self.root2threads = {} self.settings = [] self.mainSizer = mainSizer = BoxSizer(VERTICAL) mainSizer.SetSizeHints(self) self.SetSizer(mainSizer) self.Bind(EVT_CLOSE, self._on_close, self) self._logFile = logFile if logFile is None: stream = NullStream() else: try: stream = open(logFile, "a+") except: print_exc() print("Cannot log to %s" % logFile) stream = NullStream() self._logStream = stream self.logging = logging @property def logFile(self): return self._logFile @property def logging(self): return self._logging @logging.setter def logging(self, logging): if self._logging is logging: return self._logging = logging self.loggingItem.Check(logging) global globalLogStream if logging: globalLogStream = self._logStream else: globalLogStream = nullStream def _on_log(self, __): self.logging = self.loggingItem.IsChecked() def _on_add(self, _): self._add_settings(SaveSettings(self), False) def _hide_save_settings(self, save_settings): self.mainSizer.Hide(save_settings.sizer) self.mainSizer.SetSizeHints(self) self._add_show_item(save_settings) def _add_show_item(self, save_settings): save_dir = save_settings.saveDir.GetValue() if not save_dir: save_dir = "[not configured]" if len(save_dir) > SHOW_TITLE_LIMIT: save_short = ( save_dir[:SHOW_TITLE_LIMIT//2 - 3] + "..." + save_dir[SHOW_TITLE_LIMIT//2:] ) else: save_short = save_dir showItem = self.showMenu.Append(ID_ANY, save_short, save_dir) self.Bind(EVT_MENU, lambda __: self._on_show_save_settings(showItem, save_settings), showItem ) def _on_show_save_settings(self, item, save_settings): self.showMenu.Remove(item.GetId()) self._show_save_settings(save_settings) def _show_save_settings(self, save_settings): self.mainSizer.Show(save_settings.sizer) self.mainSizer.SetSizeHints(self) def add_settings(self, saveDirVal, backupDirVal, filterOutVal = None, hidden = False ): settings = SaveSettings(self, saveDirVal = saveDirVal, backupDirVal = backupDirVal ) if filterOutVal is not None: settings.filterOut.SetValue(filterOutVal) self._add_settings(settings, hidden) def _add_settings(self, settings, hidden): self.settings.append(settings) self.mainSizer.Add(settings.sizer, 0, EXPAND) if hidden: self.mainSizer.Hide(settings.sizer) self._add_show_item(settings) self.mainSizer.SetSizeHints(self) def _on_close(self, e): for threads in list(self.root2threads.values()): for t in threads: t.exit_request = True self.saveData = [s.saveData for s in self.settings] self.hidden = set( i for i, s in enumerate(self.settings) if not self.mainSizer.IsShown(s.sizer) ) e.Skip() global globalLogStream globalLogStream = nullStream self._logStream.close() def _on_about(self, _): dlg = MessageDialog(self, "Monitors save directory and backs up" " changes to backup directory. Backup directory is under Git" " version control system.\n" "\n" "Author(s):\n" "Vasiliy (real) Efimov\n", "About") dlg.ShowModal() dlg.Destroy()
def initMenus(self): self.mnuFileNew = Menu() self.mnuFileNew.Append(SharedIdentifiers.ID_MNUFILENEWPROJECT, _("&New project\tCtrl-N"), _("New project")) self.mnuFileNew.Append(SharedIdentifiers.ID_MNU_FILE_NEW_CLASS_DIAGRAM, _("New c&lass diagram\tCtrl-L"), _("New class diagram")) self.mnuFileNew.Append(SharedIdentifiers.ID_MNU_FILE_NEW_SEQUENCE_DIAGRAM, _("New s&equence diagram\tCtrl-E"), _("New sequence diagram")) self.mnuFileNew.Append(SharedIdentifiers.ID_MNU_FILE_NEW_USECASE_DIAGRAM, _("New &use-case diagram\tCtrl-U"), _("New use-case diagram")) self.fileMenu.Append(NewId(), _("&New"), self.mnuFileNew) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_INSERT_PROJECT, _("&Insert a project...\t"), _("Insert a project in the current project...")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_OPEN, _("&Open...\tCtrl-O"), _("Open a file...")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_SAVE, _("&Save\tCtrl-S"), _("Save current data")) self.fileMenu.Append(SharedIdentifiers.ID_MNUFILESAVEAS, _("Save &As...\tCtrl-A"), _("Save current data")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_PROJECT_CLOSE, _("&Close project\tCtrl-W"), _("Close current project")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_REMOVE_DOCUMENT, _("&Remove document"), _("Remove the document from the project")) self.fileMenu.AppendSeparator() sub = self.makeExportMenu() if sub is None: sub = Menu() if sub is not None: self.fileMenu.Append(NewId(), _("Export"), sub) sub = self.makeImportMenu() if sub is not None: self.fileMenu.Append(NewId(), _("Import"), sub) self.fileMenu.AppendSeparator() self.fileMenu.Append(SharedIdentifiers.ID_MENU_FILE_PYUT_PREFERENCES, _("PyUt P&references"), _("PyUt preferences")) # self.fileMenu.Append(ID_MNU_FILE_DIAGRAM_PROPERTIES,_("&Diagram Properties"), _("Diagram properties")) self.fileMenu.AppendSeparator() self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT_SETUP, _("Print se&tup..."), _("Display the print setup dialog box")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT_PREVIEW, _("Print pre&view"), _("Diagram preview before printing")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT, _("&Print\tCtrl-P"), _("Print the current diagram")) self.fileMenu.AppendSeparator() # Add Last opened files index = 0 # TODO : does not work ? verify function return... for el in self._prefs.getLastOpenedFilesList(): index += 1 # self.fileMenu.Append(self.lastOpenedFilesID[index - 1], "&" + str(index) + " " + el) lof: str = f"&{str(index)} {el}" self.logger.debug(f'self.lastOpenedFilesID[index - 1]: {self.lastOpenedFilesID[index - 1]} lof: {lof} ') self.fileMenu.Append(self.lastOpenedFilesID[index - 1], lof) for index in range(index, self._prefs.getNbLOF()): # self.fileMenu.Append(self.lastOpenedFilesID[index], "&" + str(index + 1) + " -") lofAgain: str = f"&{str(index + 1)} -" self.fileMenu.Append(self.lastOpenedFilesID[index], lofAgain) self.fileMenu.AppendSeparator() self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_EXIT, _("E&xit"), _("Exit PyUt")) mnuEdit = Menu() mnuEdit.Append(SharedIdentifiers.ID_MNU_UNDO, _("&Undo\tCtrl-Z"), _("Undo the last performed action")) mnuEdit.Append(SharedIdentifiers.ID_MNU_REDO, _("&Redo\tCtrl-Y"), _("Redo the last undone action")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_CUT, _("Cu&t\tCtrl-X"), _("Cut selected data")) mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_COPY, _("&Copy\tCtrl-C"), _("Copy selected data")) mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_PASTE, _("&Paste\tCtrl-V"), _("Paste selected data")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_SELECT_ALL, _("&Select all"), _("Select all elements")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_ADD_PYUT_HIERARCHY, _("&Add Pyut hierarchy"), _("Add the UML Diagram of Pyut")) mnuEdit.Append(SharedIdentifiers.ID_MNU_ADD_OGL_HIERARCHY, _("Add &Ogl hierarchy"), _("Add the UML Diagram of Pyut - Ogl")) if MenuCreator.DEBUG_ERROR_VIEWS is True: mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MENU_GRAPHIC_ERROR_VIEW, 'Show &Graphic Error View', 'Test graphical error view') mnuEdit.Append(SharedIdentifiers.ID_MENU_TEXT_ERROR_VIEW, 'Show &Text Error View', 'Test text error view') mnuEdit.Append(SharedIdentifiers.ID_MENU_RAISE_ERROR_VIEW, 'Show &Exception Error View', 'Test raising exception') # ----------------- # Tools menu # ----------------- mnuTools = Menu() sub = self.makeToolsMenu() if sub is not None: mnuTools.Append(NewId(), _("Plugins tools"), sub) sub = self.makeToolboxesMenu() if sub is not None: mnuTools.Append(NewId(), _("toolboxes"), sub) mnuHelp = Menu() mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_INDEX, _("&Index"), _("Display help index")) mnuHelp.AppendSeparator() mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_VERSION, _("Check for newer versions"), _("Check if a newer version of Pyut exists")) mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_WEB, _("&Web site"), _("Open PyUt web site")) mnuHelp.Append(SharedIdentifiers.ID_DEBUG, _("&Debug"), _("Open IPython shell")) mnuHelp.AppendSeparator() mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_ABOUT, _("&About PyUt..."), _("Display the About PyUt dialog box")) mnuBar = MenuBar() mnuBar.Append(self.fileMenu, _("&File")) mnuBar.Append(mnuEdit, _("&Edit")) mnuBar.Append(mnuTools, _("&Tools")) mnuBar.Append(mnuHelp, "&?") containingFrame: Frame = self._containingFrame containingFrame.SetMenuBar(mnuBar) cb: SharedTypes.CallbackMap = self._callbackMap containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_PROJECT], id=SharedIdentifiers.ID_MNUFILENEWPROJECT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_CLASS_DIAGRAM], id=SharedIdentifiers.ID_MNU_FILE_NEW_CLASS_DIAGRAM) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_SEQUENCE_DIAGRAM], id=SharedIdentifiers.ID_MNU_FILE_NEW_SEQUENCE_DIAGRAM) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_USE_CASE_DIAGRAM], id=SharedIdentifiers.ID_MNU_FILE_NEW_USECASE_DIAGRAM) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.INSERT_PROJECT], id=SharedIdentifiers.ID_MNU_FILE_INSERT_PROJECT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.FILE_OPEN], id=SharedIdentifiers.ID_MNU_FILE_OPEN) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.FILE_SAVE], id=SharedIdentifiers.ID_MNU_FILE_SAVE) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.FILE_SAVE_AS], id=SharedIdentifiers.ID_MNUFILESAVEAS) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PROJECT_CLOSE], id=SharedIdentifiers.ID_MNU_PROJECT_CLOSE) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.REMOVE_DOCUMENT], id=SharedIdentifiers.ID_MNU_FILE_REMOVE_DOCUMENT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PRINT_SETUP], id=SharedIdentifiers.ID_MNU_FILE_PRINT_SETUP) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PRINT_PREVIEW], id=SharedIdentifiers.ID_MNU_FILE_PRINT_PREVIEW) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PRINT], id=SharedIdentifiers.ID_MNU_FILE_PRINT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PYUT_PREFERENCES], id=SharedIdentifiers.ID_MENU_FILE_PYUT_PREFERENCES) # EVT_MENU(self, ID_MNU_FILE_DIAGRAM_PROPERTIES,self._OnMnuFileDiagramProperties) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EXIT_PROGRAM], id=SharedIdentifiers.ID_MNU_FILE_EXIT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PROGRAM_ABOUT], id=SharedIdentifiers.ID_MNU_HELP_ABOUT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.HELP_INDEX], id=SharedIdentifiers.ID_MNU_HELP_INDEX) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.HELP_VERSION], id=SharedIdentifiers.ID_MNU_HELP_VERSION) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.HELP_WEB], id=SharedIdentifiers.ID_MNU_HELP_WEB) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.ADD_PYUT_HIERARCHY], id=SharedIdentifiers.ID_MNU_ADD_PYUT_HIERARCHY) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.ADD_OGL_HIERARCHY], id=SharedIdentifiers.ID_MNU_ADD_OGL_HIERARCHY) if MenuCreator.DEBUG_ERROR_VIEWS is True: from org.pyut.experimental.DebugErrorViews import DebugErrorViews containingFrame.Bind(EVT_MENU, DebugErrorViews.debugGraphicErrorView, id=SharedIdentifiers.ID_MENU_GRAPHIC_ERROR_VIEW) containingFrame.Bind(EVT_MENU, DebugErrorViews.debugTextErrorView, id=SharedIdentifiers.ID_MENU_TEXT_ERROR_VIEW) containingFrame.Bind(EVT_MENU, DebugErrorViews.debugRaiseErrorView, id=SharedIdentifiers.ID_MENU_RAISE_ERROR_VIEW) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EDIT_CUT], id=SharedIdentifiers.ID_MNU_EDIT_CUT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EDIT_COPY], id=SharedIdentifiers.ID_MNU_EDIT_COPY) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EDIT_PASTE], id=SharedIdentifiers.ID_MNU_EDIT_PASTE) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.SELECT_ALL], id=SharedIdentifiers.ID_MNU_EDIT_SELECT_ALL) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.DEBUG], id=SharedIdentifiers.ID_DEBUG) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.UNDO], id=SharedIdentifiers.ID_MNU_UNDO) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.REDO], id=SharedIdentifiers.ID_MNU_REDO) for index in range(self._prefs.getNbLOF()): containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.LAST_OPENED_FILES], id=self.lastOpenedFilesID[index]) containingFrame.Bind(EVT_CLOSE, cb[ActionCallbackType.CLOSE])
class MenuCreator: DEBUG_ERROR_VIEWS: bool = True # TODO Make this a runtime flag def __init__(self, frame: Frame, callbackMap: SharedTypes.CallbackMap, lastOpenFilesID): from org.pyut.plugins.PluginManager import PluginManager # Plugin Manager should not be in plugins directory self._containingFrame: Frame = frame self._callbackMap: SharedTypes.CallbackMap = callbackMap self.lastOpenedFilesID = lastOpenFilesID self.logger: Logger = getLogger(__name__) self._prefs: PyutPreferences = PyutPreferences() self.plugMgr: PluginManager = PluginManager() self._mnuFile: Menu = Menu() self._plugins: SharedTypes.PluginMap = cast(SharedTypes.PluginMap, {}) # To store the plugins self._toolboxesID: SharedTypes.ToolboxIdMap = cast(SharedTypes.ToolboxIdMap, {}) # Association toolbox id def getFileMenu(self) -> Menu: return self._mnuFile def setFileMenu(self, theNewValue: Menu): self._mnuFile = theNewValue def getPlugins(self) -> SharedTypes.PluginMap: return self._plugins def setPlugins(self, theNewValues: SharedTypes.PluginMap): self._plugins = theNewValues def getToolboxIds(self) -> SharedTypes.ToolboxIdMap: return self._toolboxesID def setToolboxIds(self, theNewValues: SharedTypes.ToolboxIdMap): self._toolboxesID = theNewValues fileMenu: Menu = property(getFileMenu, setFileMenu) plugins: SharedTypes.PluginMap = property(getPlugins, setPlugins) toolboxIds: SharedTypes.ToolboxIdMap = property(getToolboxIds, setToolboxIds) def initMenus(self): self.mnuFileNew = Menu() self.mnuFileNew.Append(SharedIdentifiers.ID_MNUFILENEWPROJECT, _("&New project\tCtrl-N"), _("New project")) self.mnuFileNew.Append(SharedIdentifiers.ID_MNU_FILE_NEW_CLASS_DIAGRAM, _("New c&lass diagram\tCtrl-L"), _("New class diagram")) self.mnuFileNew.Append(SharedIdentifiers.ID_MNU_FILE_NEW_SEQUENCE_DIAGRAM, _("New s&equence diagram\tCtrl-E"), _("New sequence diagram")) self.mnuFileNew.Append(SharedIdentifiers.ID_MNU_FILE_NEW_USECASE_DIAGRAM, _("New &use-case diagram\tCtrl-U"), _("New use-case diagram")) self.fileMenu.Append(NewId(), _("&New"), self.mnuFileNew) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_INSERT_PROJECT, _("&Insert a project...\t"), _("Insert a project in the current project...")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_OPEN, _("&Open...\tCtrl-O"), _("Open a file...")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_SAVE, _("&Save\tCtrl-S"), _("Save current data")) self.fileMenu.Append(SharedIdentifiers.ID_MNUFILESAVEAS, _("Save &As...\tCtrl-A"), _("Save current data")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_PROJECT_CLOSE, _("&Close project\tCtrl-W"), _("Close current project")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_REMOVE_DOCUMENT, _("&Remove document"), _("Remove the document from the project")) self.fileMenu.AppendSeparator() sub = self.makeExportMenu() if sub is None: sub = Menu() if sub is not None: self.fileMenu.Append(NewId(), _("Export"), sub) sub = self.makeImportMenu() if sub is not None: self.fileMenu.Append(NewId(), _("Import"), sub) self.fileMenu.AppendSeparator() self.fileMenu.Append(SharedIdentifiers.ID_MENU_FILE_PYUT_PREFERENCES, _("PyUt P&references"), _("PyUt preferences")) # self.fileMenu.Append(ID_MNU_FILE_DIAGRAM_PROPERTIES,_("&Diagram Properties"), _("Diagram properties")) self.fileMenu.AppendSeparator() self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT_SETUP, _("Print se&tup..."), _("Display the print setup dialog box")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT_PREVIEW, _("Print pre&view"), _("Diagram preview before printing")) self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_PRINT, _("&Print\tCtrl-P"), _("Print the current diagram")) self.fileMenu.AppendSeparator() # Add Last opened files index = 0 # TODO : does not work ? verify function return... for el in self._prefs.getLastOpenedFilesList(): index += 1 # self.fileMenu.Append(self.lastOpenedFilesID[index - 1], "&" + str(index) + " " + el) lof: str = f"&{str(index)} {el}" self.logger.debug(f'self.lastOpenedFilesID[index - 1]: {self.lastOpenedFilesID[index - 1]} lof: {lof} ') self.fileMenu.Append(self.lastOpenedFilesID[index - 1], lof) for index in range(index, self._prefs.getNbLOF()): # self.fileMenu.Append(self.lastOpenedFilesID[index], "&" + str(index + 1) + " -") lofAgain: str = f"&{str(index + 1)} -" self.fileMenu.Append(self.lastOpenedFilesID[index], lofAgain) self.fileMenu.AppendSeparator() self.fileMenu.Append(SharedIdentifiers.ID_MNU_FILE_EXIT, _("E&xit"), _("Exit PyUt")) mnuEdit = Menu() mnuEdit.Append(SharedIdentifiers.ID_MNU_UNDO, _("&Undo\tCtrl-Z"), _("Undo the last performed action")) mnuEdit.Append(SharedIdentifiers.ID_MNU_REDO, _("&Redo\tCtrl-Y"), _("Redo the last undone action")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_CUT, _("Cu&t\tCtrl-X"), _("Cut selected data")) mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_COPY, _("&Copy\tCtrl-C"), _("Copy selected data")) mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_PASTE, _("&Paste\tCtrl-V"), _("Paste selected data")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_EDIT_SELECT_ALL, _("&Select all"), _("Select all elements")) mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MNU_ADD_PYUT_HIERARCHY, _("&Add Pyut hierarchy"), _("Add the UML Diagram of Pyut")) mnuEdit.Append(SharedIdentifiers.ID_MNU_ADD_OGL_HIERARCHY, _("Add &Ogl hierarchy"), _("Add the UML Diagram of Pyut - Ogl")) if MenuCreator.DEBUG_ERROR_VIEWS is True: mnuEdit.AppendSeparator() mnuEdit.Append(SharedIdentifiers.ID_MENU_GRAPHIC_ERROR_VIEW, 'Show &Graphic Error View', 'Test graphical error view') mnuEdit.Append(SharedIdentifiers.ID_MENU_TEXT_ERROR_VIEW, 'Show &Text Error View', 'Test text error view') mnuEdit.Append(SharedIdentifiers.ID_MENU_RAISE_ERROR_VIEW, 'Show &Exception Error View', 'Test raising exception') # ----------------- # Tools menu # ----------------- mnuTools = Menu() sub = self.makeToolsMenu() if sub is not None: mnuTools.Append(NewId(), _("Plugins tools"), sub) sub = self.makeToolboxesMenu() if sub is not None: mnuTools.Append(NewId(), _("toolboxes"), sub) mnuHelp = Menu() mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_INDEX, _("&Index"), _("Display help index")) mnuHelp.AppendSeparator() mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_VERSION, _("Check for newer versions"), _("Check if a newer version of Pyut exists")) mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_WEB, _("&Web site"), _("Open PyUt web site")) mnuHelp.Append(SharedIdentifiers.ID_DEBUG, _("&Debug"), _("Open IPython shell")) mnuHelp.AppendSeparator() mnuHelp.Append(SharedIdentifiers.ID_MNU_HELP_ABOUT, _("&About PyUt..."), _("Display the About PyUt dialog box")) mnuBar = MenuBar() mnuBar.Append(self.fileMenu, _("&File")) mnuBar.Append(mnuEdit, _("&Edit")) mnuBar.Append(mnuTools, _("&Tools")) mnuBar.Append(mnuHelp, "&?") containingFrame: Frame = self._containingFrame containingFrame.SetMenuBar(mnuBar) cb: SharedTypes.CallbackMap = self._callbackMap containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_PROJECT], id=SharedIdentifiers.ID_MNUFILENEWPROJECT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_CLASS_DIAGRAM], id=SharedIdentifiers.ID_MNU_FILE_NEW_CLASS_DIAGRAM) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_SEQUENCE_DIAGRAM], id=SharedIdentifiers.ID_MNU_FILE_NEW_SEQUENCE_DIAGRAM) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.NEW_USE_CASE_DIAGRAM], id=SharedIdentifiers.ID_MNU_FILE_NEW_USECASE_DIAGRAM) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.INSERT_PROJECT], id=SharedIdentifiers.ID_MNU_FILE_INSERT_PROJECT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.FILE_OPEN], id=SharedIdentifiers.ID_MNU_FILE_OPEN) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.FILE_SAVE], id=SharedIdentifiers.ID_MNU_FILE_SAVE) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.FILE_SAVE_AS], id=SharedIdentifiers.ID_MNUFILESAVEAS) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PROJECT_CLOSE], id=SharedIdentifiers.ID_MNU_PROJECT_CLOSE) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.REMOVE_DOCUMENT], id=SharedIdentifiers.ID_MNU_FILE_REMOVE_DOCUMENT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PRINT_SETUP], id=SharedIdentifiers.ID_MNU_FILE_PRINT_SETUP) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PRINT_PREVIEW], id=SharedIdentifiers.ID_MNU_FILE_PRINT_PREVIEW) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PRINT], id=SharedIdentifiers.ID_MNU_FILE_PRINT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PYUT_PREFERENCES], id=SharedIdentifiers.ID_MENU_FILE_PYUT_PREFERENCES) # EVT_MENU(self, ID_MNU_FILE_DIAGRAM_PROPERTIES,self._OnMnuFileDiagramProperties) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EXIT_PROGRAM], id=SharedIdentifiers.ID_MNU_FILE_EXIT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.PROGRAM_ABOUT], id=SharedIdentifiers.ID_MNU_HELP_ABOUT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.HELP_INDEX], id=SharedIdentifiers.ID_MNU_HELP_INDEX) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.HELP_VERSION], id=SharedIdentifiers.ID_MNU_HELP_VERSION) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.HELP_WEB], id=SharedIdentifiers.ID_MNU_HELP_WEB) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.ADD_PYUT_HIERARCHY], id=SharedIdentifiers.ID_MNU_ADD_PYUT_HIERARCHY) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.ADD_OGL_HIERARCHY], id=SharedIdentifiers.ID_MNU_ADD_OGL_HIERARCHY) if MenuCreator.DEBUG_ERROR_VIEWS is True: from org.pyut.experimental.DebugErrorViews import DebugErrorViews containingFrame.Bind(EVT_MENU, DebugErrorViews.debugGraphicErrorView, id=SharedIdentifiers.ID_MENU_GRAPHIC_ERROR_VIEW) containingFrame.Bind(EVT_MENU, DebugErrorViews.debugTextErrorView, id=SharedIdentifiers.ID_MENU_TEXT_ERROR_VIEW) containingFrame.Bind(EVT_MENU, DebugErrorViews.debugRaiseErrorView, id=SharedIdentifiers.ID_MENU_RAISE_ERROR_VIEW) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EDIT_CUT], id=SharedIdentifiers.ID_MNU_EDIT_CUT) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EDIT_COPY], id=SharedIdentifiers.ID_MNU_EDIT_COPY) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EDIT_PASTE], id=SharedIdentifiers.ID_MNU_EDIT_PASTE) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.SELECT_ALL], id=SharedIdentifiers.ID_MNU_EDIT_SELECT_ALL) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.DEBUG], id=SharedIdentifiers.ID_DEBUG) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.UNDO], id=SharedIdentifiers.ID_MNU_UNDO) containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.REDO], id=SharedIdentifiers.ID_MNU_REDO) for index in range(self._prefs.getNbLOF()): containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.LAST_OPENED_FILES], id=self.lastOpenedFilesID[index]) containingFrame.Bind(EVT_CLOSE, cb[ActionCallbackType.CLOSE]) def makeExportMenu(self): """ Make the export submenu. """ plugs = self.plugMgr.getOutputPlugins() nb = len(plugs) if nb == 0: return None sub: Menu = Menu() cb: SharedTypes.CallbackMap = self._callbackMap for i in range(nb): pluginId = NewId() obj = plugs[i](None, None) sub.Append(pluginId, obj.getOutputFormat()[0]) self._containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.EXPORT], id=pluginId) self.plugins[pluginId] = plugs[i] return sub def makeImportMenu(self): """ Make the import submenu. """ plugs = self.plugMgr.getInputPlugins() nb = len(plugs) if nb == 0: return None sub: Menu = Menu() cb: SharedTypes.CallbackMap = self._callbackMap for i in range(nb): importId = NewId() obj = plugs[i](None, None) sub.Append(importId, obj.getInputFormat()[0]) self._containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.IMPORT], id=importId) self.plugins[importId] = plugs[i] return sub def makeToolsMenu(self): """ Make the tools submenu. """ plugs = self.plugMgr.getToolPlugins() nb = len(plugs) if nb == 0: return None sub: Menu = Menu() cb: SharedTypes.CallbackMap = self._callbackMap for i in range(nb): wxId = NewId() obj = plugs[i](None, None) sub.Append(wxId, obj.getMenuTitle()) self._containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.TOOL_PLUGIN], id=wxId) self.plugins[wxId] = plugs[i] return sub def makeToolboxesMenu(self): """ Make the toolboxes submenu. """ mediator: Mediator = Mediator() # Get categories categories = mediator.getToolboxesCategories() nb = len(categories) if nb == 0: return None sub: Menu = Menu() cb: SharedTypes.CallbackMap = self._callbackMap for category in categories: categoryId = NewId() self._toolboxesID[categoryId] = category sub.Append(categoryId, category) self._containingFrame.Bind(EVT_MENU, cb[ActionCallbackType.TOOL_BOX_MENU], id=categoryId) return sub
def CreatePopupMenu(self): menu = Menu() appMenuItem = menu.Append(ID_ANY, "mHosts v" + Settings.version()) if sys.platform != "linux": appMenuItem.Enable(False) appMenuItem.SetBitmap( Bitmap(ResPath("icons/logo.png"), BITMAP_TYPE_PNG)) menu.Append(self.ID_TOGGLE, r"%s主窗口" % ("隐藏" if self.__window.IsShown() else "显示")) menu.AppendSeparator() for hosts in Settings.settings["hosts"]: item = MenuItem(menu, hosts["id"], hosts["name"], kind=ITEM_CHECK) item.Enable(not hosts['alwaysApply']) menu.Append(item) menu.Check(hosts["id"], hosts["active"] or hosts["alwaysApply"]) self.Bind(EVT_MENU, self.__window.OnTaskBarHostsMenuClicked, id=hosts["id"]) newHostMenu = Menu() newHostMenu.Append(self.ID_NEW, "新建") if sys.platform != "linux": newHostMenu.Append(self.ID_IMPORT, "导入").Enable(False) menu.Append(-1, "新建Hosts方案", newHostMenu) menu.AppendSeparator() menu.Append(self.ID_REFRESH_DNS, u"刷新DNS缓存") if os.path.exists(Settings.settings["chromePath"]): chromeMenu = Menu() chromeMenu.Append(self.ID_LUNCH_CHROME, "直接启动") chromeMenu.Append(self.ID_LUNCH_CHROME_CROS, "允许跨域请求") chromeMenu.Append(self.ID_LUNCH_CHROME_NO_PLUGINS, "禁用所有插件") menu.Append(-1, "启动 Google Chrome 浏览器", chromeMenu) menu.AppendSeparator() menu.Append(self.ID_ABOUT, "关于") menu.Append(self.ID_EXIT, "退出") self.menu = menu return menu
class MainFrame(Frame): def __init__(self, parent, dpi=(1, 1)): Frame.__init__(self, parent, id=ID_ANY, title=u" mHosts - v" + Settings.version(), pos=DefaultPosition, size=Size(700 * dpi[0], 500 * dpi[1]), style=DEFAULT_FRAME_STYLE | SYSTEM_MENU | TAB_TRAVERSAL) self.SetIcon(Icon(iconPath, BITMAP_TYPE_ICO)) self.SetSizeHints(Size(500 * dpi[0], 350 * dpi[1])) self.menuBar = MenuBar(0) self.menuFile = Menu() self.menuItemNew = MenuItem(self.menuFile, ID_ANY, u"新建(&N)", EmptyString, ITEM_NORMAL) self.menuItemImport = MenuItem(self.menuFile, ID_ANY, u"导入(&I)", EmptyString, ITEM_NORMAL) if sys.platform != "linux": self.menuItemImport.Enable(False) self.menuFile.Append(self.menuItemNew) self.menuFile.Append(self.menuItemImport) self.menuFile.AppendSeparator() self.menuItemExit = MenuItem(self.menuFile, ID_ANY, u"退出(&Q)", EmptyString, ITEM_NORMAL) self.menuFile.Append(self.menuItemExit) self.menuBar.Append(self.menuFile, u"文件(&F)") self.menuHelp = Menu() self.menuItemSettings = MenuItem(self.menuHelp, ID_ANY, u"首选项(&P)", EmptyString, ITEM_NORMAL) if sys.platform != "linux": self.menuItemSettings.Enable(False) self.menuHelp.Append(self.menuItemSettings) self.menuItemHelpDoc = MenuItem(self.menuHelp, ID_ANY, u"帮助文档(&D)", EmptyString, ITEM_NORMAL) self.menuHelp.Append(self.menuItemHelpDoc) self.menuItemCheckUpdate = MenuItem(self.menuHelp, ID_ANY, u"检查更新(&U)", EmptyString, ITEM_NORMAL) self.menuHelp.Append(self.menuItemCheckUpdate) self.menuItemAbout = MenuItem(self.menuHelp, ID_ANY, u"关于(&A)", EmptyString, ITEM_NORMAL) self.menuHelp.Append(self.menuItemAbout) self.menuBar.Append(self.menuHelp, u"帮助(&H)") self.SetMenuBar(self.menuBar) self.statusBar = StatusBar(self, ID_ANY, STB_SIZEGRIP) statusBarFont = Font(10, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL, False, EmptyString) self.statusBar.SetFont(statusBarFont) self.SetStatusBar(self.statusBar) bSizer1 = BoxSizer(HORIZONTAL) self.images = {} self.imageList = ImageList(width=12, height=12) iconList = GetIcons().items() for name, bitmap in iconList: self.images[name] = self.imageList.Add(bitmap) self.hostsTree = TreeCtrl(self, ID_ANY, Point(0, 0), Size(180 * dpi[0], -1), TR_DEFAULT_STYLE) self.hostsTree.SetImageList(self.imageList) bSizer1.Add(self.hostsTree, 0, EXPAND, 5) # self.hostsListView = CheckListBox(self, size=Size(size[0] / 9, -1)) # bSizer1.Add(self.hostsListView, 0, EXPAND, 5) # WARNING: wxPython code generation isn't supported for this widget yet. self.codeEditor = CodeView(self, dpi) bSizer1.Add(self.codeEditor, 1, EXPAND, 5) self.SetSizer(bSizer1) self.Layout() self.Centre(BOTH) # Connect Events self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemNew.GetId()) self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemExit.GetId()) self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemAbout.GetId()) self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemHelpDoc.GetId()) self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemSettings.GetId()) self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemImport.GetId()) self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemCheckUpdate.GetId()) def __del__(self): pass def Destroy(self): self.imageList.Destroy() Frame.Destroy(self) # Virtual event handlers, overide them in your derived class def OnMenuClicked(self, event): event.Skip()
def CreatePopupMenu(self): menu = Menu() for mentAttr in self.getMenuAttrs(): menu.Append(mentAttr[1], mentAttr[0]) return menu