def run(self): # instance_name = None while True: app = wx.App(False) instance_name = "%s-%s" % (app.GetAppName(), wx.GetUserId()) instance_checker = wx.SingleInstanceChecker( instance_name, self.working_path) if instance_checker.IsAnotherRunning(): dlg = wx.MessageDialog( None, u"SwitchHosts! 已经在运行了或上次没有正常退出,要重新打开吗?", u"SwitchHosts!", wx.YES_NO | wx.ICON_QUESTION) ret_code = dlg.ShowModal() if ret_code != wx.ID_YES: dlg.Destroy() return dlg.Destroy() frame = MainFrame( mainjob=self, instance_name=instance_name, size=(640, 480), version=self.VERSION, working_path=self.working_path, taskbar_icon=self.taskbar_icon, ) self.restart = False self.taskbar_icon = None self.app = app self.frame = frame self.bindEvents() frame.Centre() frame.Show() app.MainLoop() app.Destroy() time.sleep(0.1) if not self.restart: break
def run(self): instance_name = None while True: app = wx.App() instance_name = "%s-%s" % (app.GetAppName(), wx.GetUserId()) instance_checker = wx.SingleInstanceChecker( instance_name, self.working_path) if instance_checker.IsAnotherRunning(): wx.MessageBox(u"SwitchHosts! 已经在运行了!") open(os.path.join(self.working_path, ".active"), "w").write("1") return frame = MainFrame( mainjob=self, instance_name=instance_name, size=(640, 480), version=self.VERSION, working_path=self.working_path, taskbar_icon=self.taskbar_icon, ) self.restart = False self.taskbar_icon = None self.app = app self.frame = frame self.bindEvents() frame.Centre() frame.Show() app.MainLoop() app.Destroy() time.sleep(0.1) if not self.restart: break
def run(self): while True: app = wx.App() frame = MainFrame( mainjob=self, size=(640, 480), version=self.VERSION, working_path=self.pwd, taskbar_icon=self.taskbar_icon, ) self.restart = False self.taskbar_icon = None frame.Centre() frame.Show() app.MainLoop() app.Destroy() time.sleep(0.1) if not self.restart: break