def PageChanged(self, old_selection, new_selection): # don't do anything if the page doesn't actually change if old_selection == new_selection: return # notify old active child that it has been deactivated if old_selection != -1 and old_selection < self.GetPageCount(): old_child = self.GetPage(old_selection) if not old_child: raise Exception( "AuiMDIClientWindow.PageChanged - null page pointer") event = wx.ActivateEvent(wx.wxEVT_ACTIVATE, False, old_child.GetId()) event.SetEventObject(old_child) old_child.GetEventHandler().ProcessEvent(event) # notify new active child that it has been activated if new_selection != -1: active_child = self.GetPage(new_selection) if not active_child: raise Exception( "AuiMDIClientWindow.PageChanged - null page pointer") event = wx.ActivateEvent(wx.wxEVT_ACTIVATE, True, active_child.GetId()) event.SetEventObject(active_child) active_child.GetEventHandler().ProcessEvent(event) if active_child.GetMDIParentFrame(): active_child.GetMDIParentFrame().SetActiveChild(active_child) active_child.GetMDIParentFrame().SetChildMenuBar(active_child)
def Destroy(self): pParentFrame = self.GetMDIParentFrame() if not pParentFrame: raise Exception("Missing MDI Parent Frame") pClientWindow = pParentFrame.GetClientWindow() if not pClientWindow: raise Exception("Missing MDI Client Window") if pParentFrame.GetActiveChild() == self: # deactivate ourself event = wx.ActivateEvent(wx.wxEVT_ACTIVATE, False, self.GetId()) event.SetEventObject(self) self.GetEventHandler().ProcessEvent(event) pParentFrame.SetActiveChild(None) pParentFrame.SetChildMenuBar(None) for pos in xrange(pClientWindow.GetPageCount()): if pClientWindow.GetPage(pos) == self: return pClientWindow.DeletePage(pos) return False
def OpenNewWindow(self, fname=u'', caller=None): """Open a new window @keyword fname: Open a file in the new window """ frame = ed_main.MainWindow(None, wx.ID_ANY, Profile_Get('WSIZE'), ed_glob.PROG_NAME) if caller: pos = caller.GetPosition() frame.SetPosition((pos.x + 22, pos.y + 22)) self.RegisterWindow(repr(frame), frame, True) self.SetTopWindow(frame) if isinstance(fname, basestring) and fname != u'': frame.DoOpen(ed_glob.ID_COMMAND_LINE_OPEN, fname) frame.Show(True) # Ensure frame gets an Activate event when shown # this doesn't happen automatically on windows wx.PostEvent(frame, wx.ActivateEvent(wx.wxEVT_ACTIVATE, True))
def test_ActivateEvent_ctor(self): evt = wx.ActivateEvent()
def Main(): """Configures and Runs an instance of Editra @summary: Parses command line options, loads the user profile, creates an instance of Editra and starts the main loop. """ opts, args = ProcessCommandLine() # We are ready to run so fire up the config and launch the app profile_updated = InitConfig() # Put extern subpackage on path so that bundled external dependancies # can be found if needed. if not hasattr(sys, 'frozen'): epath = os.path.join(os.path.dirname(__file__), 'extern') if os.path.exists(epath): sys.path.append(epath) # Create Application dev_tool.DEBUGP("[main][app] Initializing application...") editra_app = Editra(False) # Print ipc server authentication info if '--auth' in opts: opts.remove('--auth') print "port=%d,key=%s" % (ed_ipc.EDPORT, profiler.Profile_Get('SESSION_KEY')) # Check if this is the only instance, if its not exit since # any of the opening commands have already been passed to the # master instance if not editra_app.IsOnlyInstance(): dev_tool.DEBUGP("[main][info] Second instance exiting...") editra_app.Destroy() os._exit(0) if profile_updated: # Make sure window iniliazes to default position profiler.Profile_Del('WPOS') wx.MessageBox(_("Your profile has been updated to the latest " "version") + u"\n" + \ _("Please check the preferences dialog to check " "your preferences"), _("Profile Updated")) # Splash a warning if version is not a final version if profiler.Profile_Get('APPSPLASH'): import edimage splash_img = edimage.splashwarn.GetBitmap() splash = wx.SplashScreen(splash_img, wx.SPLASH_CENTRE_ON_PARENT | \ wx.SPLASH_NO_TIMEOUT, 0, None, wx.ID_ANY) splash.Show() if profiler.Profile_Get('SET_WSIZE'): wsize = profiler.Profile_Get('WSIZE') else: wsize = (700, 450) frame = ed_main.MainWindow(None, wx.ID_ANY, wsize, ed_glob.PROG_NAME) frame.Maximize(profiler.Profile_Get('MAXIMIZED')) editra_app.RegisterWindow(repr(frame), frame, True) editra_app.SetTopWindow(frame) frame.Show(True) # Load Session Data # But not if there are command line args for files to open if profiler.Profile_Get('SAVE_SESSION', 'bool', False) and not len(args): frame.GetNotebook().LoadSessionFiles() # Unlike wxMac/wxGTK Windows doesn't post an activate event when a window # is first shown, so do it manually to make sure all event handlers get # pushed. if wx.Platform == '__WXMSW__': wx.PostEvent(frame, wx.ActivateEvent(wx.wxEVT_ACTIVATE, True)) if 'splash' in locals(): splash.Destroy() # Do update check, only check if its been more than a day since the last # check if profiler.Profile_Get('CHECKUPDATE', default=True): uthread = updater.UpdateThread(editra_app, ID_UPDATE_CHECK) uthread.start() for arg in args: try: arg = os.path.abspath(arg) fname = ed_txt.DecodeString(arg, sys.getfilesystemencoding()) frame.DoOpen(ed_glob.ID_COMMAND_LINE_OPEN, fname) except IndexError: dev_tool.DEBUGP("[main][err] IndexError on commandline args") # 3. Start Applications Main Loop dev_tool.DEBUGP("[main][info] Starting MainLoop...") editra_app.MainLoop() dev_tool.DEBUGP("[main][info] MainLoop finished exiting application") os._exit(0)
frame = ed_main.MainWindow(None, wx.ID_ANY, wsize, ed_glob.PROG_NAME) frame.Maximize(profiler.Profile_Get('MAXIMIZED')) editra_app.RegisterWindow(repr(frame), frame, True) editra_app.SetTopWindow(frame) frame.Show(True) # Load Session Data # But not if there are command line args for files to open if profiler.Profile_Get('SAVE_SESSION', 'bool', False) and not len(args): frame.GetNotebook().LoadSessionFiles() # Unlike wxMac/wxGTK Windows doesn't post an activate event when a window # is first shown, so do it manually to make sure all event handlers get # pushed. if wx.Platform == '__WXMSW__': wx.PostEvent(frame, wx.ActivateEvent(wx.wxEVT_ACTIVATE, True)) if 'splash' in locals(): splash.Destroy() # Do update check, only check if its been more than a day since the last # check tval = sum(time.localtime(time.time())[:3]) if profiler.Profile_Get('CHECKUPDATE', default=True) and \ tval - profiler.Profile_Get('LASTCHECK', 'int', default=0) > 1: profiler.Profile_Set('LASTCHECK', tval) uthread = updater.UpdateThread(editra_app, ID_UPDATE_CHECK) uthread.start() for arg in args: try: