def ShowModal(self): eg.EnsureVisible(self) return wx.Dialog.ShowModal(self)
def __init__(self, document): """ Create the MainFrame """ self.document = document self.findDialog = None self.openDialogs = [] self.lastClickedTool = None self.egEvent = None self.lastFocus = None wx.Frame.__init__(self, None, -1, document.GetTitle(), pos=Config.position, size=(1, 1), style=self.style) self.SetMinSize((400, 200)) document.frame = self auiManager = wx.aui.AuiManager(self, wx.aui.AUI_MGR_DEFAULT) self.auiManager = auiManager self.logCtrl = self.CreateLogCtrl() self.corConst = self.logCtrl.GetWindowBorderSize()[0] + \ wx.SystemSettings.GetMetric(wx.SYS_VSCROLL_X) self.treeCtrl = self.CreateTreeCtrl() self.toolBar = self.CreateToolBar() self.menuBar = self.CreateMenuBar() self.statusBar = StatusBar(self) self.SetStatusBar(self.statusBar) # tree popup menu self.popupMenu = self.CreateTreePopupMenu() iconBundle = wx.IconBundle() iconBundle.AddIcon(eg.taskBarIcon.stateIcons[0]) icon = wx.EmptyIcon() icon.LoadFile(join(eg.imagesDir, "icon32x32.png"), wx.BITMAP_TYPE_PNG) iconBundle.AddIcon(icon) self.SetIcons(iconBundle) self.Bind(wx.EVT_ICONIZE, self.OnIconize) self.Bind(wx.EVT_MENU_OPEN, self.OnMenuOpen) self.Bind(wx.EVT_CLOSE, self.OnClose) self.mainSizeFlag = True self.ratioLock = False self.ratio = Config.ratio self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_MOVE, self.OnMove) self.Bind(wx.aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose) self.Bind(wx.aui.EVT_AUI_PANE_MAXIMIZE, self.OnPaneMaximize) self.Bind(wx.aui.EVT_AUI_PANE_RESTORE, self.OnPaneRestore) self.UpdateViewOptions() self.SetSize(Config.size) eg.Bind("DocumentFileChange", self.OnDocumentFileChange) eg.Bind("DocumentChange", self.OnDocumentChange) eg.Bind("DialogCreate", self.OnAddDialog) eg.Bind("DialogDestroy", self.OnRemoveDialog) eg.Bind("UndoChange", self.OnUndoChange) self.OnUndoChange(document.undoState) eg.Bind("SelectionChange", self.OnSelectionChange) if document.selection is not None: self.OnSelectionChange(document.selection) eg.Bind("FocusChange", self.OnFocusChange) self.OnFocusChange(self.treeCtrl) eg.Bind("ClipboardChange", self.OnClipboardChange) # tell FrameManager to manage this frame if (Config.perspective is not None): try: auiManager.LoadPerspective(Config.perspective, False) except: pass artProvider = auiManager.GetArtProvider() artProvider.SetMetric(wx.aui.AUI_DOCKART_PANE_BORDER_SIZE, 0) artProvider.SetMetric(wx.aui.AUI_DOCKART_GRADIENT_TYPE, wx.aui.AUI_GRADIENT_HORIZONTAL) artProvider.SetColour(wx.aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR, eg.colour.inactiveCaption) artProvider.SetColour( wx.aui.AUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR, eg.colour.inactiveCaptionGradient) artProvider.SetColour(wx.aui.AUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR, eg.colour.inactiveCaptionTextColour) auiManager.GetPane("tree").Caption(" " + Text.Tree.caption) self.toolBar.Show(Config.showToolbar) auiManager.Update() auiManager.GetPane("logger").MinSize((100, 100))\ .Caption(" " + Text.Logger.caption) # create an accelerator for the "Log only assigned and activated # events" checkbox. An awful hack. @eg.LogIt def ToggleOnlyLogAssigned(dummyEvent): checkBox = self.statusBar.checkBox flag = not checkBox.GetValue() checkBox.SetValue(flag) eg.config.onlyLogAssigned = flag self.statusBar.SetCheckBoxColour(flag) toggleOnlyLogAssignedId = wx.NewId() wx.EVT_MENU(self, toggleOnlyLogAssignedId, ToggleOnlyLogAssigned) # find the accelerator key in the label of the checkbox labelText = eg.text.MainFrame.onlyLogAssigned result = re.search(r'&([a-z])', labelText, re.IGNORECASE) if result: hotKey = result.groups()[0].upper() else: hotKey = "L" # create an accelerator for the "Del" key. This way we can temporarily # disable it while editing a tree label. # (see TreeCtrl.py OnBeginLabelEdit and OnEndLabelEdit) def OnDelKey(dummyEvent): self.DispatchCommand('OnCmdDelete') delId = wx.NewId() wx.EVT_MENU(self, delId, OnDelKey) def OnEnterKey(dummyEvent): if self.lastFocus == self.treeCtrl.editControl: self.treeCtrl.EndEditLabel(self.treeCtrl.editLabelId, False) enterId = wx.NewId() wx.EVT_MENU(self, enterId, OnEnterKey) self.acceleratorTable = wx.AcceleratorTable([ (wx.ACCEL_NORMAL, wx.WXK_DELETE, delId), (wx.ACCEL_NORMAL, wx.WXK_RETURN, enterId), (wx.ACCEL_ALT, ord(hotKey), toggleOnlyLogAssignedId), ]) self.SetAcceleratorTable(self.acceleratorTable) self.logCtrl.Bind(wx.EVT_SIZE, self.OnLogCtrlSize) eg.EnsureVisible(self)
def Show(self, show=True): if show: eg.EnsureVisible(self) wx.Dialog.Show(self, show)