def __createToolbar(self, toolbarInfo, id): if toolbarInfo is None: return toolbar = wx.ToolBar(self._window, id, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TB_FLAT | wx.TB_NODIVIDER) index = 0 for itemInfo in toolbarInfo.values(): itemId = id * 100 + index if itemInfo.getImage() is None or '' == itemInfo.getImage().strip(): continue imagePath = Application.getSettings().getWorkPath() + os.path.sep + itemInfo.getImage() bmp = wx.Bitmap(imagePath, wx.BITMAP_TYPE_PNG) toolbar.AddLabelTool(itemId, itemInfo.getName(), bmp, longHelp=itemInfo.getTip()) action = Application.getActionManager().getAction(itemInfo.getAction()) if action is not None: toolbar.Bind(wx.EVT_TOOL, action.execute, id=itemId) index += 1 if 0 == index: return None toolbar.Realize() return toolbar
def __onPageClose(self, evt): selectIndex = evt.GetSelection() if 0 <= selectIndex and self._auiNotebook.GetPageCount() > selectIndex: editor = self._auiNotebook.GetPage(selectIndex) if editor is None or not self.__getOpenedDocuments().has_key(editor): return closeAction = Application.getActionManager().getAction('DocumentActions.Close') if closeAction is not None: closeAction.execute(None)
def __onClose(self, evt): ''' close all documents ''' closeAllFileAction = Application.getActionManager().getAction('DocumentActions.Close All') if closeAllFileAction is not None: closeAllFileAction.execute(None) ''' close all panes ''' self.getLayoutManager().clear() ''' destroy frame ''' self.Destroy()
def execute(self, evt): document = Application.getDocumentManager().getCurrentDocument() if document is None: return if document.isContentChanged(): if ( wx.MessageDialog( None, "Do you want to save file: %s?" % document.getName(), "Warning", wx.YES | wx.NO | wx.ICON_WARNING, ).ShowModal() == wx.ID_YES ): saveAction = Application.getActionManager().getAction("DocumentActions.Save") if saveAction is not None: saveAction.execute(None) document.close()
def __createMenu(self, menuInfo, parentMenu): menu = None if parentMenu == self.__getMenubar() or 0 < len(menuInfo.getChildren().keys()): menu = wx.Menu() self.__getMenubar().Append(menu, menuInfo.getName()) else: if '-' == menuInfo.getName(): parentMenu.AppendSeparator() else: menu = parentMenu.Append(-1, menuInfo.getName(), menuInfo.getTip()) if menuInfo.getAction() is not None and '' != menuInfo.getAction(): action = Application.getActionManager().getAction(menuInfo.getAction()) if action is not None: self._window.Bind(wx.EVT_MENU, action.execute, menu) for sub in menuInfo.getChildren().values(): self.__createMenu(sub, menu)