def OnClose(self, e): try: self.server.close_all() wx.Exit() except: pass wx.Exit()
def OnClose(self, event): """ Close the app. """ try: if (self.simulation.isStopped): wx.Exit() else: self.OnStop(wx.EVT_CLOSE) except AttributeError: wx.Exit()
def MenuDone(self, choice): self.toolmenu.Hide() if choice == "exitresume": print(f"Exit method: {choice}.") print("Freeing snippets.") self.snip.freeall() print("Restoring non-scratch registers.") self.amiga.setregs(self.savedregs) print("Enable.") self.execlib.Enable() if self.amiga.debugger == "SAD": self.execlib.exitdebugloop() self.amiga.setreg("d0", 0) self.amiga.resume() wx.Exit() elif choice == "exitreset": print(f"Exit method: {choice}.") self.amiga.reboot() wx.Exit() elif choice == "exithardreset": print(f"Exit method: {choice}.") self.amiga.poke32(self.execlib.base + self.execlib.ColdCapture, 0) self.amiga.poke32(self.execlib.base + self.execlib.WarmCapture, 0xFFFFFFFF) self.amiga.reboot() wx.Exit() elif choice == "exitdebug": print(f"Exit method: {choice}.") print("Freeing snippets.") self.snip.freeall() print("Restoring non-scratch registers.") self.amiga.setregs(self.savedregs) self.amiga.setreg("d0", 0) print("Enable.") self.execlib.Enable() if self.amiga.debugger == "SAD": self.execlib.exitdebugloop() wx.Exit() elif choice == "floppytool": wx.CallAfter(self.floppytool) elif choice == "bootblocktool": wx.CallAfter(self.bootblocktool) elif choice == "dostool": wx.CallAfter(self.dostool) elif choice == "romtool": wx.CallAfter(self.romtool) else: print(f"Choice {choice} isn't implemented.") return
def emergency_exit(message): """Handle emergency exits. Warn the user, log, and exit to terminal with the given message""" logger.critical( "emergency_exit(): Emergency exit has been triggered! Giving user message " + "dialog and saving the logfile...") logger.critical("emergency_exit(): The error is: " + message) #Warn the user. DialogTools.show_msg_dlg( message="Emergency exit triggered.\n\n" + message + "\n\nYou'll now be asked for a location to save the log file.\n" + "If you email me at [email protected] with the contents of that " + "file I'll be happy to help you fix this problem.", kind="error") #Shut down the logger. logging.shutdown() #Save the log file. log_file = DialogTools.show_save_file_dlg(wildcard="Log Files|*.log") start_process("mv -v /tmp/wxfixboot.log " + log_file, show_output=False) #Exit. DialogTools.show_msg_dlg(message="Done. WxFixBoot will now exit.") wx.Exit() sys.stdout.write(message + "\n") os._exit( 1) #TODO Is there a better alternative that will work from a thread?
def _on_menu_select(self, event): """Do actions of menu items.""" event_id = event.GetId() if event_id == wx.ID_OPEN: self._open_callback() elif event_id == wx.ID_CLOSE: wx.Exit()
def start(self): wx_app = wx.App(redirect=False) frame = CalibrationFrame(debug=self.debug) eyetracker = TobiiEyeTracker(api=self.api, gui=frame) worker = CalibrationThread(wx_app, frame, eyetracker) worker.start() frame.ShowFullScreen(True) frame.Show(True) wx_app.MainLoop() print("Exited main loop") print("Killing calibration thread") worker.join() print("Killed calibration thread") print("Exiting wxPython") wx.Exit() print("Exited wxPython") print("Exiting process with a success") exit(0)
def OnButton(self, evt): dlg = wx.FileDialog( self, message="Choose Word 2007/2003 file:", defaultDir=os.getcwd(), defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR ) if dlg.ShowModal() == wx.ID_OK: paths = dlg.GetPaths() GenerateSupport() for path in paths: input = path output = os.path.splitext(input)[0]+'.pdf' self.frame.SetTitle(u'正在转换文档--->'+path) if (not os.path.isabs(input)): input = os.path.abspath(input) if (not os.path.isabs(output)): output = os.path.abspath(output) doc2pdf(input, output) self.frame.SetTitle('OK:-->'+output) mdlg = wx.MessageDialog(None, u"转换已完成,是否继续转换?", u"标题信息", wx.YES_NO | wx.ICON_QUESTION) if mdlg.ShowModal() == wx.ID_YES: self.frame.SetTitle('please choose a file') else: self.Close(True) wx.Exit() mdlg.Destroy() dlg.Destroy()
def OnCloseWindow(self, event): self.scope.pa.stop() self.time1.Stop() if 'cameras' in dir(self.scope): for c in self.scope.cameras.values(): c.Shutdown() else: self.scope.cam.Shutdown() for f in self.scope.CleanupFunctions: f() print 'All cleanup functions called' time.sleep(1) import threading print 'Remaining Threads:' for t in threading.enumerate(): print t, t._Thread__target #self.int_sl.Destroy() #self.piezo_sl.Destroy() #self.seq_d.Destroy() #self.Close() self.Destroy() wx.Exit()
def __init__(self, parent, title, about): try: wx.Dialog.__init__(self, parent, -1, title, size=tuple(about['SIZE'])) t = self.ABOUT % about['HTML'] except Exception as e: wx.MessageBox(str(e), 'ConfigError', wx.OK | wx.ICON_ERROR) wx.Exit() self.html = wx.html.HtmlWindow(self) self.html.SetPage(t) button = wx.Button(self, wx.ID_OK, "OK") sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.html, 1, wx.EXPAND | wx.ALL, 5) sizer.Add(button, 0, wx.ALIGN_CENTER | wx.ALL, 5) self.html.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) self.SetSizer(sizer) self.Centre() self.Layout()
def OnCloseWindow(self, event): self.scope.frameWrangler.stop() self.time1.Stop() if 'cameras' in dir(self.scope): for c in self.scope.cameras.values(): c.Shutdown() else: self.scope.cam.Shutdown() for f in self.scope.CleanupFunctions: f() logging.info('All cleanup functions called') time.sleep(1) import threading msg = 'Remaining Threads:\n' for t in threading.enumerate(): if six.PY3: msg += '%s, %s\n' % (t.name, t._target) else: msg += '%s, %s\n' % (t, t._Thread__target) logging.info(msg) self.Destroy() wx.Exit()
def Login_in(self, evt): """ 输入密码正确则登录至主界面,否则还有三次机会输入错误则退出 :param evt:单击确定 """ UserName = self.Username.GetValue() PassWord = self.Password.GetValue() if self.ct == 0: wx.Exit() elif (UserName == 'admin') and (PassWord == 'rocky'): self.Destroy() dlg = wx.MessageDialog(None, "登陆成功!", "成功", wx.YES_DEFAULT | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() frame2 = MyForm() frame2.Show(True) elif (UserName != 'admin') or (PassWord != "rocky"): dlg = wx.MessageDialog(None, "ID或Password输入错误,您还有可以尝试%d次!" % (self.ct), "错误", wx.YES_DEFAULT | wx.ICON_WARNING) self.ct -= 1 if dlg.ShowModal() == wx.ID_YES: dlg.Destroy()
def _onShutdownTimer(self, event): allDone = False if (self._shutdownTimerCounter >= 1000): if (self._cameraServer != None): self._cameraServer.forceCameraWebServerProcessToStop() allDone = True else: if ((self._cameraServer == None) or (self._cameraServer.hasCameraWebServerProcessShutdownNicely()) ): print "All done. (shutdown timer counter: " + str( self._shutdownTimerCounter) + " )" allDone = True if (allDone == False): self._shutdownTimerCounter += 1 if (self._shutdownTimerCounter > 200): print "Shutdown timeout!!! Force killing rest..." if ((self._cameraServer != None) and (self._cameraServer. hasCameraWebServerProcessShutdownNicely() == False)): self._cameraServer.forceCameraWebServerProcessToStop() allDone = True if (allDone == True): if (sys.platform != "darwin"): self.Destroy() wx.Exit() #@UndefinedVariable if ((self._fullscreenMode == True) and (sys.platform != "darwin")): applicationHolder.Exit() sys.exit() print "Closeing done."
def __init__(self): wx.adv.TaskBarIcon.__init__(self) self.SetIcon(wx.Icon(self.ICON), self.TITLE) # 设置图标和标题 self.Bind(wx.EVT_MENU, self.onAbout, id=self.ID_ABOUT) # 绑定“关于”选项的点击事件 self.Bind(wx.EVT_MENU, self.onExit, id=self.ID_EXIT) # 绑定“退出”选项的点击事件 self.Bind(wx.EVT_MENU, self.onShowWeb, id=self.ID_SHOW_WEB) # 绑定“显示页面”选项的点击事件 if github_username == '' or repository_name == '': wx.MessageBox(text[3], "Warning") wx.Exit() self.frame2 = Trans(parent=None, title='上传中', size=(50, 20)) self.frame2.Center() self.frame2.Show(False) self.frame3 = Trans(parent=None, title='上传成功', size=(50, 20)) self.frame3.Center() self.frame3.Show(False) self.frame4 = Trans(parent=None, title='上传失败', size=(50, 20)) self.frame4.Center() self.frame4.Show(False) threadkey = ThreadKey(self) threadkey.start()
def call_insert(self, event): """ 登録処理を呼び出す Parameters ---------- event : event wxPythonのeventクラス """ error_flag, temp_text = self.create_check_text() if error_flag: return wx.MessageBox("最低限1行入力して、登録データを作成してください", "入力エラー", wx.ICON_ERROR) dlg = wx.MessageDialog(None, f"{temp_text}", ' 登録内容確認', wx.YES_NO | wx.ICON_INFORMATION) result = dlg.ShowModal() if result == wx.ID_YES: insert_info = self.create_insert_list() error_msg = accountingService.insert_accounting(insert_info) if error_msg is not False: return wx.MessageBox(error_msg, "Error", wx.ICON_ERROR) wx.MessageBox("登録完了しました。", "登録完了", wx.ICON_INFORMATION) self.frame.Destroy() wx.Exit() mainGui.call_mainGui() dlg.Destroy()
def on_exit(self, event): threading.Condition() global breakout, stop breakout = True stop_all = True wx.Exit() exit(0)
def startThreads( self ): self.grabFrameOK = False self.listenerThread = SocketListener( self.requestQ, self.messageQ ) error = self.listenerThread.test() if error: wx.MessageBox('Socket Error:\n\n{}\n\nIs another CrossMgrVideo or CrossMgrCamera running on this computer?'.format(error), "Socket Error", wx.OK | wx.ICON_ERROR ) wx.Exit() self.camInQ, self.camReader = CamServer.getCamServer( self.getCameraInfo() ) self.cameraThread = threading.Thread( target=self.processCamera ) self.cameraThread.daemon = True self.eventThread = threading.Thread( target=self.processRequests ) self.eventThread.daemon = True self.dbWriterThread = threading.Thread( target=DBWriter, args=(self.dbWriterQ, lambda: wx.CallAfter(self.delayRefreshTriggers), self.db.fname) ) self.dbWriterThread.daemon = True self.cameraThread.start() self.eventThread.start() self.dbWriterThread.start() self.listenerThread.start() self.grabFrameOK = True self.messageQ.put( ('threads', 'Successfully Launched') ) self.primaryFreq = 5 self.camInQ.put( {'cmd':'send_update', 'name':'primary', 'freq':self.primaryFreq} ) return True
def startThreads(self): self.grabFrameOK = False self.listenerThread = SocketListener(self.requestQ, self.messageQ) error = self.listenerThread.test() if error: wx.MessageBox( 'Socket Error:\n\n{}\n\nIs another CrossMgrVideo or CrossMgrCamera running on this computer?' .format(error), "Socket Error", wx.OK | wx.ICON_ERROR) wx.Exit() self.dbWriterThread = threading.Thread(target=DBWriter, args=(self.dbWriterQ, )) self.dbWriterThread.daemon = True self.dbReaderThread = threading.Thread(target=DBReader, args=(self.dbReaderQ, self.setFinishStripJpgs)) self.dbReaderThread.daemon = True self.fcb = FrameCircBuf(int(self.bufferSecs * self.fps)) self.listenerThread.start() self.dbWriterThread.start() self.dbReaderThread.start() self.grabFrameOK = True self.messageQ.put(('threads', 'Successfully Launched')) return True
def button_handler(self, event): button_clicked = event.EventObject if button_clicked.GetLabel() != ' ': dialog = wx.MessageDialog(None, 'Cell is already in use', 'Cell Message', wx.OK | wx.ICON_ERROR) dialog.ShowModal() else: move = Move(self.next_player.counter, button_clicked.row, button_clicked.col) self.make_a_move(move) finished = False if self.board.check_for_winner(self.next_player): self.show_winner_message(self.next_player) finished = True if finished == False and self.board.is_full(): print('Game is a Tie') self.show_tie_message() finished = True if finished: print('Goodbye') wx.Exit() if self.next_player == self.first_player: self.next_player = self.second_player else: self.next_player = self.first_player
def __init__(self, serPort, cfg, gpios, adcs, dacs): wx.Frame.__init__(self, None, -1, "Quick Controller") self.panel = wx.Panel(self) self.txtFields = [] self.config = cfg try: self.BoardComm = TransLayer(serPort, cfg.getVref(), cfg.getRes()) time.sleep(1) except IOError: wx.MessageBox("Could not open serial port %s" % serPort, style=wx.ICON_EXCLAMATION) self.Close() wx.Exit() self.ctlDic = {'gpio': {}, 'adc': {}, 'dac': {}} gpiobox = self.MakeGpioCluster(gpios) adcbox = self.MakeAdcCluster(adcs) dacbox = self.MakeDacCluster(dacs) sizer = wx.BoxSizer(wx.VERTICAL) # add the controls only if required if gpiobox != None: sizer.Add(gpiobox, 0, wx.ALL, 10) if adcbox != None: sizer.Add(adcbox, 0, wx.ALL, 10) if dacbox != None: sizer.Add(dacbox, 0, wx.ALL, 10) self.statusBar = self.CreateStatusBar() font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT) font.SetPointSize(10) self.panel.SetSizer(sizer) sizer.Fit(self)
def OnCloseWindow(self, event): if not self.table_exist: # print "from flex_3d_frame self.myGrid = None" event.Skip() else: # print "from flex_3d_frame self.myGrid .NEQ. None" wx.Exit()
def OnInit(self): HOST, PORT = socket.gethostname(), 61955 argvs = sys.argv instance_name = u"%s-%s" % (self.GetAppName(), wx.GetUserId()) self.instance = wx.SingleInstanceChecker(instance_name) if self.instance.IsAnotherRunning(): if len(argvs) >= 2: self.client(HOST, PORT, argvs) wx.Exit() else: server = self.start_server(HOST, PORT) # タスクトレイ self.tb_ico = wx.TaskBarIcon() self.tb_ico.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnTbiLeftDClick) self.tb_ico.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTbiRightUp) self.ico = wx.Icon("homu.ico", wx.BITMAP_TYPE_ICO) self.tb_ico.SetIcon(self.ico, u"homuhomu") # タスクトレイ用メニューの作成 self.menu = wx.Menu() self.menu.Append(1, u"Exit(&X)") wx.EVT_MENU(self.menu, 1, self.OnClose) self.Frm = wx.Frame(None, -1, "homuLauncher", size=(400, 60), pos=(400, 400)) self.TxtCtr = wx.TextCtrl(self.Frm, -1) self.Frm.Show() return 1
def OnDialogClose(self): ''' Dialog close event handler; ''' # Exit the app; wx.Exit()
def EDF_to_NAFC(filename, HdrDict): hdr = list() oK = False temp = dict() Updateshiptripstn = False afiletype = FileTypeIs(filename) if afiletype == "MK21_EDF": f = open(filename, "r") Read_EDF_File_Hdr(f, hdr) Parse_EDF_Nafc_File_Hdr(hdr, HdrDict) fileout = HdrDict["hdr0"]["OUTFILE"] if fileout[0:8] == "00000000": Updateshiptripstn = True msg = "ENTER OUTPUT FILE TO CREATE" condition = True while condition: FileOK = True fileout = save_file_dialog(fileout) if fileout != None: try: fout = open(fileout, "w") except IOError: print("bad filename or path.. by") msg = "Bad name or path " + fileout + " edit or Cancel" FileOK = False if (fileout == None) or FileOK: condition = False # end of loop if fileout == None: wx.Exit() exit() # when the input XBT file had no Sequence number if Updateshiptripstn == True: hdr1 = HdrDict["hdr1"] hdr4 = HdrDict["hdr4"] hdr8 = HdrDict["hdr8"] hdr1["SHIP"] = os.path.basename(fileout)[0:2] hdr1["TRIP"] = os.path.basename(fileout)[2:5] hdr1["STN"] = os.path.basename(fileout)[5:8] hdr4["SHIP"] = hdr1["SHIP"] hdr4["TRIP"] = hdr1["TRIP"] hdr4["STN"] = hdr1["STN"] hdr8["SHIP"] = hdr1["SHIP"] hdr8["TRIP"] = hdr1["TRIP"] hdr8["STN"] = hdr1["STN"] Write_EDF_Nafc_File_Hdr(fout, hdr, HdrDict) Copy_EDF_File_Data(f, fout) f.close() fout.close() return (fileout)
def OnClose(event): # os.removedirs('spinwaves_temp') try: os.remove('csection_calc_data.npz') except: pass wx.Exit()
def _close_final(): # There is a window, or an activated display global _do_loop if _do_loop: _do_loop = False # make sure we don't trigger this twice while True: # at end of user program, wait for user to close the program rate(1) _wx.Exit()
def __del__(self): try: self.BoardComm.Close() except: pass wx.Exit() return
def onExit(self, event): self.SetIcon(wx.Icon(self.ICON), '正在退出...稍等1-2分钟') # 设置图标和标题 self.windowhandler.Hide() self.logger.debug('菜单退出 点击事件') # 退出时记得把logger的句柄移除,否则永远卡死在handler的emit里 self.logger.removeHandler( gl.get_value('logger').loggingRedirectHandler) wx.Exit()
def _OnCloseWindow(self, event): for window in self.GetChildren(): if isinstance(window, wx.Frame): if not window.Close(): return self.Destroy() #app.ExitMainLoop() wx.Exit()
def OnExit(self, evt): """退出菜单事件处理""" # 从托盘删除图标 self.taskBar.RemoveIcon() # 退出 wx.Exit()
def _OnKeyDown(self, event): key = event.GetKeyCode() if _ESCAPE: if key == wx.WXK_ESCAPE: wx.Exit() return event.Skip() # forward event return