我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.YES_NO。
def writePhonebookEntry(self, pos, name='', number=''): if self.abortedRead: dlg = wxskinMessageDialog(self, "Did not finish reading your entire SIM card phonebook.\nAs a result, this may overwrite any exisiting phonebook contacts that have not been read yet!\n\nDo you wish to continue anyway?", 'Overwrite warning', wx.YES_NO | wx.ICON_WARNING) ret = dlg.ShowModal() dlg.Destroy() if ret == wx.ID_NO: return wx.ID_NO else: self.abortedRead = 0 if not name: data = "FF" * self.recordLength else: GSMnumber = StringToGSMPhoneNumber(number) data = "%s%s%sFFFF" % ( padString(hexlify(ASCIIToGSM3_38(name)), self.nameLength << 1, "F"), IntToHex(len(GSMnumber) / 2), padString(GSMnumber, 22, 'F')) pdu = self.updateRecordPDU % (IntToHex(pos), IntToHex(self.recordLength), data) self.SIM.sendAPDUmatchSW(pdu, SW_OK) return wx.ID_YES
def OnPopupDeleteAll(self, event): dlg = wxskinMessageDialog(self, self.delete_confirm_text, 'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION) ret = dlg.ShowModal() dlg.Destroy() if ret == wx.ID_YES: dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL) try: self.SIM.gotoFile(SMS_FILE_PATH) i = 1 for key in self.itemDataMap.keys()[:]: # Make a copy of key table!! if not dlg.Update(i): break self.writeSMSEntry(key) del self.itemDataMap[key] i += 1 except: print_exc() pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error") dlg.Destroy() self.UpdateView() # Override the column sorting function. We need to compare 'a' and 'A' as equal
def OnStartButton(self, e): if wpkg_running(): dlg_msg = _(u"WPKG is currently running,\n" u"please wait a few seconds and try again.") dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return dlg_title = _(u"2. Warning") dlg_msg = _(u"Close all open programs!\n\nThe System could restart without further confirmation!\n\n" \ u"Continue?") dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() # Disable/enable buttons and disable Close Window option! self.startButton.Disable() self.abortButton.Enable() self.EnableCloseButton(enable=False) # Set Start Time self.wpkg_start_time = datetime.datetime.now() # Reset Log self.log = None startWorker(self.LongTaskDone, self.LongTask)
def OnAbortButton(self, e): if not self.running: self.Close() return dlg_title = _(u"Cancel") dlg_msg = _(u"System update in progress!\n\n Canceling this Progress could result in installation issues.\n" u"Cancel?") dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() if not self.running: # WPKG Process by this client has finished, no cancel possible return print 'Aborting WPKG Process' #TODO: MOVE TO DEBUG LOGGER self.shouldAbort = True msg = 'Cancel' try: pipeHandle = CreateFile("\\\\.\\pipe\\WPKG", GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None) except pywintypes.error, (n, f, e): print "Error when generating pipe handle: %s" % e #TODO: MOVE TO DEBUG LOGGER return 1 SetNamedPipeHandleState(pipeHandle, PIPE_READMODE_MESSAGE, None, None) WriteFile(pipeHandle, msg)
def close(self, event): if not self._world: event.Skip() return modified = False for level in self._world.levels: modified = modified | level.modified if modified: result = wx.MessageBox('Do you want to save your changes?', 'Unsaved changes', wx.YES_NO | wx.CANCEL | wx.ICON_EXCLAMATION) if result == wx.YES: self._world.save() elif result == wx.CANCEL: return event.Skip()
def CheckSaveBeforeClosing(self, title=_("Close Project")): """Function displaying an question dialog if project is not saved" :returns: False if closing cancelled. """ if not self.Controler.ProjectIsSaved(): dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION) answer = dialog.ShowModal() dialog.Destroy() if answer == wx.ID_YES: self.SaveProject() elif answer == wx.ID_CANCEL: return False for idx in xrange(self.TabsOpened.GetPageCount()): window = self.TabsOpened.GetPage(idx) if not window.CheckSaveBeforeClosing(): return False return True # ------------------------------------------------------------------------------- # File Menu Functions # -------------------------------------------------------------------------------
def OnDeleteButton(self, event): filepath = self.ManagedDir.GetPath() if os.path.isfile(filepath): folder, filename = os.path.split(filepath) dialog = wx.MessageDialog(self, _("Do you really want to delete the file '%s'?") % filename, _("Delete File"), wx.YES_NO | wx.ICON_QUESTION) remove = dialog.ShowModal() == wx.ID_YES dialog.Destroy() if remove: os.remove(filepath) self.ManagedDir.RefreshTree() event.Skip()
def CopyFile(self, src, dst): if os.path.isfile(src): src_folder, src_filename = os.path.split(src) if os.path.isfile(dst): dst_folder, dst_filename = os.path.split(dst) else: dst_folder = dst dst_filepath = os.path.join(dst_folder, src_filename) if os.path.isfile(dst_filepath): dialog = wx.MessageDialog( self, _("The file '%s' already exist.\nDo you want to replace it?") % src_filename, _("Replace File"), wx.YES_NO | wx.ICON_QUESTION) copy = dialog.ShowModal() == wx.ID_YES dialog.Destroy() else: copy = True if copy: shutil.copyfile(src, dst_filepath) return dst_filepath return None
def CheckProjectPathPerm(self, dosave=True): if CheckPathPerm(self.ProjectPath): return True if self.AppFrame is not None: dialog = wx.MessageDialog( self.AppFrame, _('You must have permission to work on the project\nWork on a project copy ?'), _('Error'), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) answer = dialog.ShowModal() dialog.Destroy() if answer == wx.ID_YES: if self.SaveProjectAs(): self.AppFrame.RefreshTitle() self.AppFrame.RefreshFileMenu() self.AppFrame.RefreshPageTitles() return True return False
def OnClose(self,event): if self.CHANGES_TO_BE_SAVED: dlg=wx.MessageDialog(self, "There are Unsaved Changes..Don't You Want to Save them?",'', wx.YES_NO|wx.YES_DEFAULT | wx.ICON_QUESTION) #dlg = wx.MessageDialog(None, ) #dlg = wx.MessageDialog(None, "Don't You Want to Save Changes?", wx.NO_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.Save_Clicked(None) self.Parent.IsGridChild=0 self.Parent.Show() self.P=None self.DB=None event.Skip()
def on_proceed(self, event): # wxGlade: promote.<event_handler> msg="Are sure you want to delete ?" dlg = wx.MessageDialog(self, msg,"Warning", wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal()# == wx.ID_YES if result==wx.ID_YES: try: self.delete() dlg = wx.MessageDialog(self, 'Successfully deleted students from this class', '',wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() except: dlg = wx.MessageDialog(self, 'Some error occured.Could not complete', '',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() self.check_list_box_1.Check(0,False) self.button_proceed.Enable(False) self.load_students() event.Skip()
def OnDelete(self, evt): name = self.combo_box_1.GetValue() fpath = os.path.join(DataPath, name) if name != "default": msg_dialog = wx.MessageDialog(self, "Are you sure that you want to delete file \"%s\"" % name, "Delete \"%s\"" % name, wx.YES_NO | wx.ICON_EXCLAMATION) msg_dialog.Centre(wx.BOTH) r = msg_dialog.ShowModal() if r == wx.ID_YES: if os.path.exists(fpath) and os.path.isfile(fpath): os.remove(fpath) index = self.combo_box_1.GetSelection() self.combo_box_1.Delete(index) self.combo_box_1.Select(0) msg_dialog.Destroy() else: msg_dialog = wx.MessageDialog(self, "\"%s\" can't be deleted.\nYou can edit it only." % name, "\"%s\" can't be deleted." % name, wx.OK | wx.ICON_ERROR) msg_dialog.Centre(wx.BOTH) msg_dialog.ShowModal() msg_dialog.Destroy()
def OnSet(self, evt): name = self.combo_box_1.GetValue() fpath = os.path.join(DataPath, name) msg_dialog = wx.MessageDialog(self, "Are you sure that you want to set file \"%s\" as current hosts" % name, "Set \"%s\"" % name, wx.YES_NO | wx.ICON_EXCLAMATION) msg_dialog.Centre(wx.BOTH) r = msg_dialog.ShowModal() if r == wx.ID_YES: with open(fpath, "rb") as fp_src: with open("/etc/hosts", "wb") as fp_des: fp_des.write(fp_src.read()) self.current = name with open(CurrentHosts, "wb") as fp: fp.write(name) self.statusbar.SetStatusText("Current: %s" % self.current) msg_dialog.Destroy()
def Run( self ): fileName = GetBoard().GetFileName() if len(fileName)==0: wx.LogMessage("a board needs to be saved/loaded!") else: dirpath = os.path.abspath(os.path.expanduser(fileName)) path, fname = os.path.split(dirpath) ext = os.path.splitext(os.path.basename(fileName))[1] name = os.path.splitext(os.path.basename(fileName))[0] LogMsg="reading from "+ dirpath out_filename=path+os.sep+name+".dxf" LogMsg+="writing to "+out_filename content=[] txtFile = open(fileName,"r") content = txtFile.readlines() content.append(" ") txtFile.close() #wx.MessageDialog(None, 'This is a message box. ONLY TEST!', 'Test', wx.OK | wx.ICON_INFORMATION).ShowModal() #wx.MessageDialog(None, 'This is a message box. ONLY TEST!', content, wx.OK | wx.ICON_INFORMATION).ShowModal() #found_selected=False #board = pcbnew.GetBoard() dlg=wx.MessageBox( 'Only SAVED board file will be exported to DXF file', 'Confirm', wx.OK | wx.CANCEL | wx.ICON_INFORMATION ) if dlg == wx.OK: if os.path.isfile(out_filename): dlg=wx.MessageBox( 'Overwrite DXF file?', 'Confirm', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION ) if dlg == wx.YES: export_dxf(content, out_filename) else: export_dxf(content, out_filename)
def read_config(self): try: self.config = PadConfig() except ConfigException as e: msg = "Config error: {}. Load defaults?".format(e) dlg = wx.MessageDialog(self.pnl, msg, "Config Error", wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES dlg.Destroy() if result: self.config = PadConfig(load_defaults=True) else: sys.exit(1) for key, item in self._config_map.items(): item.Set3StateValue(getattr(self.config, key))
def onClose(self,event): dlg = wx.MessageDialog(self,message="Would you like to save the coordinates before exiting?",style = wx.YES_NO | wx.YES_DEFAULT) result = dlg.ShowModal() if result == wx.ID_YES: print "Saving..." self.onSave(event) else: print "Discarding changes..." # Pass this on to the default handler. event.Skip()
def OnChkCopyFile(self, event): if not event.IsChecked(): dial = wx.MessageDialog(None, 'Are you sure? Disabling copy means that files are removed from their source location.', 'Disable copy?', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) retCode = dial.ShowModal() if (retCode != wx.ID_YES): self.chkCopyFiles.SetValue(True) dial.Destroy()
def WorkSpace(self,e ): ''' Load in a project. ''' logging.exception(self.clargs) dbfile = self.clargs['project'] if not os.path.isfile(dbfile): dlg = wx.MessageDialog(self, 'Project not found. Browse for the file?', '',wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_QUESTION) val = dlg.ShowModal() if val == wx.ID_YES: self.OpenFile(e,False) elif val == wx.ID_CANCEL: dlg.Destroy() else: self.OpenFile(False,dbfile) self.bplay.SetBitmapLabel(self.bplayicon) self.panel2.Refresh() #update timeline view self.Layout() self.panel3.SetFocus()
def OnPopupDeleteAll(self, event): dlg = wxskinMessageDialog(self, self.delete_confirm_text, 'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION) ret = dlg.ShowModal() dlg.Destroy() if ret == wx.ID_YES: dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL) try: self.SIM.gotoFile(LND_FILE_PATH) if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE): raise "Access conditions not met." i = 1 for key in self.itemDataMap.keys()[:]: # Make a copy of key table!! if not dlg.Update(i): break self.writePhonebookEntry(key) del self.itemDataMap[key] i += 1 except: print_exc() pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error") dlg.Destroy() self.UpdateView() # Override the column sorting function. We need to compare 'a' and 'A' as equal
def OnPopupDeleteAll(self, event): dlg = wxskinMessageDialog(self, self.delete_confirm_text, 'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION) ret = dlg.ShowModal() dlg.Destroy() if ret == wx.ID_YES: dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL) try: self.SIM.gotoFile(self.filepath) if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE): raise "Access conditions not met." i = 1 for key in self.itemDataMap.keys()[:]: # Make a copy of key table!! if not dlg.Update(i): break self.writePhonebookEntry(key) del self.itemDataMap[key] i += 1 except: print_exc() pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error") dlg.Destroy() self.UpdateView() # Override the column sorting function. We need to compare 'a' and 'A' as equal
def OnButtonSave(self, msg): if not self.model.status: wx.MessageBox('No export file has been successfully loaded yet!') return ret = wx.MessageBox('Overwrite the original file?', 'Attention!', wx.YES_NO | wx.ICON_QUESTION) if ret == wx.YES: self.model.save(self.fileread.path)
def ok_click(self, e): # check for changes to cron if self.cron_lamp_on.GetLabel() == "not found" or self.cron_lamp_off.GetLabel() == "not found": mbox = wx.MessageDialog(None, "Add new job to cron?", "Are you sure?", wx.YES_NO|wx.ICON_QUESTION) sure = mbox.ShowModal() if sure == wx.ID_YES: if self.cron_lamp_on.GetLabel() == "not found": cron_task = "/home/pi/Pigrow/scripts/switches/" + "lamp_on.py" MainApp.cron_info_pannel.add_to_onetime_list("new", "True", self.new_on_string_text.GetLabel(), cron_task) if self.cron_lamp_off.GetLabel() == "not found": cron_task = "/home/pi/Pigrow/scripts/switches/" + "lamp_off.py" MainApp.cron_info_pannel.add_to_onetime_list("new", "True", self.new_off_string_text.GetLabel(), cron_task) MainApp.cron_info_pannel.update_cron_click("e") elif not self.new_on_string_text.GetLabel() == self.cron_lamp_on.GetLabel() or not self.new_off_string_text.GetLabel() == self.cron_lamp_off.GetLabel(): print(":" + self.new_on_string_text.GetLabel() + ":") print(":" + self.cron_lamp_on.GetLabel() + ":") mbox = wx.MessageDialog(None, "Update cron timing?", "Are you sure?", wx.YES_NO|wx.ICON_QUESTION) sure = mbox.ShowModal() result_on = 'done' # these are for cases when only one is changed result_off = 'done' # if it attempts to update cron and fails it'll change to an error message if sure == wx.ID_YES: if not self.new_on_string_text.GetLabel() == self.cron_lamp_on.GetLabel(): result_on = self.change_cron_trigger("lamp_on.py", self.new_on_string_text.GetLabel()) if not self.new_off_string_text.GetLabel() == self.cron_lamp_off.GetLabel(): result_off = self.change_cron_trigger("lamp_off.py", self.new_off_string_text.GetLabel()) if result_on != "done" or result_off != "done": wx.MessageBox('Cron update error, edit lamp switches in the cron pannel', 'Info', wx.OK | wx.ICON_INFORMATION) else: MainApp.cron_info_pannel.update_cron_click("e") # check for changes to settings file time_lamp_on = str(self.on_hour_spin.GetValue()) + ":" + str(self.on_min_spin.GetValue()) time_lamp_off = str(self.off_hour_spin.GetValue()) + ":" + str(self.off_min_spin.GetValue()) if not MainApp.config_ctrl_pannel.config_dict["time_lamp_on"] == time_lamp_on or not MainApp.config_ctrl_pannel.config_dict["time_lamp_off"] == time_lamp_off: MainApp.config_ctrl_pannel.config_dict["time_lamp_on"] = time_lamp_on MainApp.config_ctrl_pannel.config_dict["time_lamp_off"] = time_lamp_off MainApp.config_ctrl_pannel.update_setting_click("e") MainApp.config_ctrl_pannel.update_config_click("e") self.Destroy()
def OnDisconnect(self, event): msgbox = wx.MessageDialog(None, "",u'???????',wx.YES_NO | wx.ICON_QUESTION) ret = msgbox.ShowModal() if (ret == wx.ID_YES): self.StopThreads() wx.MessageBox( u"??????",u'\n??????????') sys.exit()
def OnCloseWindow(self, event): msgbox = wx.MessageDialog(None, u"??????????????????",u'????????',wx.YES_NO | wx.ICON_QUESTION) ret = msgbox.ShowModal() if (ret == wx.ID_YES): self.StopThreads() time.sleep(0.5) sys.exit()
def MsgDlg(window, string, caption='OFAImage', style=wx.YES_NO | wx.CANCEL): """Common MessageDialog.""" dlg = wx.MessageDialog(window, string, caption, style) result = dlg.ShowModal() dlg.Destroy() return result
def updateRecordModel(self, evt): global recordStatus if recordStatus == "?": dlg = wx.MessageDialog(self, u"1. ????????????????????;\n2. ???????????????????????;\n3. ??????????????", u"?????????", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: recordStatus="?" global recordTimeDelay recordTimeDelay = int(self.recordTimeOut.GetValue()) print("??????????", recordTimeDelay) dlg.Destroy() else: recordStatus="?" self.Parent.updateRecordStatus(recordStatus)
def OnEditorShown(self, evt): if evt.GetRow() == 6 and evt.GetCol() == 3 and \ wx.MessageBox("Are you sure you wish to edit this cell?", "Checking", wx.YES_NO) == wx.NO: evt.Veto() return print "OnEditorShown: (%d,%d) %s\n" % (evt.GetRow(), evt.GetCol(), evt.GetPosition()) evt.Skip()
def OnEditorHidden(self, evt): if evt.GetRow() == 6 and evt.GetCol() == 3 and \ wx.MessageBox("Are you sure you wish to finish editing this cell?", "Checking", wx.YES_NO) == wx.NO: evt.Veto() return print "OnEditorHidden: (%d,%d) %s\n" % (evt.GetRow(), evt.GetCol(), evt.GetPosition()) evt.Skip()
def getUpdateResponse(message, caption, updateURL): if gui.messageBox(message, caption, wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.YES: W10UpdateDownloader([updateURL]).start()
def onOk(self, evt): # #39: Prompt if switching from stable to development channel. currentUpdateChannel = config.conf["wintenApps"]["updateChannel"] newUpdateChannel = ("dev", "stable")[self.channels.GetSelection()] if currentUpdateChannel == "stable" and newUpdateChannel == "dev": if gui.messageBox( # Translators: The confirmation prompt displayed when changing to development channel (with risks involved). _("You are about to switch to development updates channel. Although updates from this channel brings exciting features, it also comes with updates that might be unstable at times and should be used for testing and sending feedback to the add-on developer. If you prefer to use stable releases, please answer no and switch to stable update channel. Are you sure you wish to switch to the development update channel?"), # Translators: The title of the channel switch confirmation dialog. _("Switching to unstable channel"), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION, self ) == wx.NO: return global updateChecker if updateChecker and updateChecker.IsRunning(): updateChecker.Stop() config.conf["wintenApps"]["autoUpdateCheck"] = self.autoUpdateCheckbox.Value config.conf["wintenApps"]["updateCheckTimeInterval"] = self.updateInterval.Value if not self.updateInterval.Value: config.conf["wintenApps"]["updateCheckTime"] = 0 updateChecker = None else: updateChecker = wx.PyTimer(autoUpdateCheck) currentTime = time.time() whenToCheck = currentTime+(self.updateInterval.Value * addonUpdateCheckInterval) updateChecker.Start(whenToCheck-currentTime, True) config.conf["wintenApps"]["updateChannel"] = ("dev", "stable")[self.channels.GetSelection()] self.Destroy()
def create_callable(self, name, action): def callable(event): # check if this is for whole project or file/directory if 'item' in name.lower(): # for one single item - file/directory if not self.datafile: return full_cmd = action.format(path=self.datafile.source) else: # for whole project - root file/directory full_cmd = action.format(path=self.model.suite.source) # RideLogMessage(name + " clicked: " + fullCmd).publish() if full_cmd.lower().startswith('http'): wx.LaunchDefaultBrowser(full_cmd) else: try: subprocess.Popen(full_cmd) except OSError as error: s = "This is the error we got trying to execute {executor_name} executable file:\n" \ "\"{error}\"\n\n" \ "Probably this file in not in your PATH. Try to reinstall {executor_name}.\n" \ "Do you want to open download page?".format(error=error.strerror, executor_name=self.MENU_NAME) dlg = wx.MessageDialog(parent=self.frame, caption="Hmm, something went wrong...", message=s, style=wx.YES_NO | wx.CENTER | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: wx.LaunchDefaultBrowser(self.SVN_INSTALLATION_URL) dlg.Destroy() return callable
def doMove(self,move,score): if move: self.putTile() self.drawChange(score) if self.isGameOver(): if wx.MessageBox(u"????????????",u"??", wx.YES_NO|wx.ICON_INFORMATION)==wx.YES: bstScore = self.bstScore self.initGame() self.bstScore = bstScore self.drawAll()
def CheckElementIsUsedBeforeDeletion(self, check_function, title, name): if not check_function(name): return True dialog = wx.MessageDialog( self, _("\"%s\" is used by one or more POUs. Do you wish to continue?") % name, title, wx.YES_NO | wx.ICON_QUESTION) answer = dialog.ShowModal() dialog.Destroy() return answer == wx.ID_YES
def CheckNewProjectPath(self, old_project_path, new_project_path): if old_project_path == new_project_path: message = (_("Save path is the same as path of a project! \n")) dialog = wx.MessageDialog(self.AppFrame, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() return False else: plc_file = os.path.join(new_project_path, "plc.xml") if os.path.isfile(plc_file): message = (_("Selected directory already contains another project. Overwrite? \n")) dialog = wx.MessageDialog(self.AppFrame, message, _("Error"), wx.YES_NO | wx.ICON_ERROR) answer = dialog.ShowModal() return answer == wx.ID_YES return True
def _StartInkscape(self): svgfile = self._getSVGpath() open_inkscape = True if not self.GetCTRoot().CheckProjectPathPerm(): dialog = wx.MessageDialog(self.GetCTRoot().AppFrame, _("You don't have write permissions.\nOpen Inkscape anyway ?"), _("Open Inkscape"), wx.YES_NO | wx.ICON_QUESTION) open_inkscape = dialog.ShowModal() == wx.ID_YES dialog.Destroy() if open_inkscape: if not os.path.isfile(svgfile): svgfile = None open_svg(svgfile)
def yes_no(info, title="ImagePy Yes-No ?!"): dlg = wx.MessageDialog(curapp, info, title, wx.YES_NO | wx.CANCEL) rst = dlg.ShowModal() dlg.Destroy() dic = {wx.ID_YES:'yes', wx.ID_NO:'no', wx.ID_CANCEL:'cancel'} return dic[rst]
def OnRemoveClick(self, event): # wxGlade: MyFrame.<event_handler> self.remove_row_index msg="This student along with all data will be deleted\nAre you sure you want to Delete this row?" if wx.MessageBox(msg, "Want to Delete?", wx.YES_NO) == wx.YES: removed_item=self.CURRENT_LIST[0][self.remove_row_index+1] #print "removing",removed_item self.DB.RemoveScore(removed_item[4]) #Passing score id #Checking if the student has any other record in any other div query='SELECT * FROM T1 WHERE STUDENT_ID=?' self.DB.cur.execute(query,(removed_item[1],)) if self.DB.cur.fetchone()==None: self.DB.RemoveStudent(removed_item[1]) #passing student_id else: print 'other records exixts' if self.SUBJECT=="Basic Science": removed_item2=self.CURRENT_LIST[1][self.remove_row_index] removed_item3=self.CURRENT_LIST[2][self.remove_row_index] self.CURRENT_LIST[1].remove(removed_item2) self.CURRENT_LIST[2].remove(removed_item3) self.grid_1.DeleteRows(self.remove_row_index,1) #except: #print "Error in removing row" event.Skip()
def on_finished(self, event): # wxGlade: sampoorna_win.<event_handler> if self.button_finished.Label=="Abort": msg="Do you want to abort this operation?" dlg = wx.MessageDialog(self, msg,"Warning", wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal()# == wx.ID_YES if result==wx.ID_YES: self.thread.stop() self.Close() dlg.Destroy() else: self.Close() event.Skip()# end of class sampoorna_win
def ok_clicked(self,event): msg='The spreadsheet must have data in 3 columns in the order of Roll No, Admission No, Name.' msg+=' It assumes first row carries headings and student data begins only from the second row.Do you want to proceed ?' dlg = wx.MessageDialog(self, msg,"Excel Format", wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal()# == wx.ID_YES if result==wx.ID_YES: self.I=import_excel_operations(self,self.YEAR,self.CLASS,self.DIV) self.I.do() dlg.Destroy() else: self.Close()
def on_hlink(self, event): # wxGlade: student_profie.<event_handler> new_acd_win=add_academic_year(self) new_acd_win.ShowModal() new_year=new_acd_win.NEW_YEAR if not new_year: new_acd_win.Destroy() return 0 new_acd_win.Destroy() years=self.DB.Get_Years() if years.count(int(new_year)): msg= "Acdemic year "+str(new_year)+"-"+str(int(new_year)+1)+"already exists" dlg = wx.MessageDialog(self,msg, 'Error Adding',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return years.sort() msg="Do you want to add new academic year "+new_year+"-"+str(int(new_year)+1) dlg = wx.MessageDialog(self, msg,"Add Year?", wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal()# == wx.ID_YES if result==wx.ID_NO: dlg.Destroy() return 0 dlg.Destroy() self.DB.Add_Div(new_year,'8','A') self.DB.Add_Div(new_year,'9','A') self.DB.Add_Div(new_year,'10','A') self.load_year() event.Skip()
def db_delete(self): msg="The student "+self.text_ctrl_name.Value+", along with all data, will be deleted\nAre you sure you want to continue?" dlg = wx.MessageDialog(self, msg,"Warning", wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal()# == wx.ID_YES if result==wx.ID_NO: return 0 dlg.Destroy() try: self.DB.Remove_Student_Full(self.combo_box_adno.GetStringSelection()) msg="Successfully Removed Student" icon=wx.ICON_INFORMATION except: msg="Failed to Remove the Student" icon=wx.ICON_ERROR dlg = wx.MessageDialog(self, msg, '',wx.OK | icon) dlg.ShowModal() dlg.Destroy() self.load_admission_no() self.clear_student_details() self.button_delete.Disable()
def update(self, count): self.progressBar.Update(count) if self.progressBar.Update(count)[0] == 0: cancelMsg = wx.MessageDialog(None, "Are you sure you want to cancel?",'Continue?',wx.YES_NO | wx.ICON_QUESTION) cancelMsgAnswer = cancelMsg.ShowModal() if cancelMsgAnswer == wx.ID_YES: return False else: self.progressBar.Resume() return True
def PreExit(self): msg = 'GriPy Application is preparing to terminate....' log.info(msg) print '\n', msg OM = ObjectManager(self) if OM.get_changed_flag(): dial = wx.MessageDialog(self.GetTopWindow(), 'Do you want to save your project?', 'GriPy', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION ) if dial.ShowModal() == wx.ID_YES: self.on_save() # self.reset_ObjectManager() # app_UI_filename = self._gripy_app_state.get('app_UI_file') Interface.save_UI_application_data(app_UI_filename) user_UI_filename = self._gripy_app_state.get('user_UI_file') Interface.save_UI_user_data(user_UI_filename) # This time I choose not use the line below because there was a little # freeze on exiting (1-2 seconds). Then I opted delegate it do compiler. #UIM = UIManager() #UIM.close() UIM = UIManager() UIM.PreExit() # As indicated by https://forums.wxwidgets.org/viewtopic.php?t=32138 aui_manager = wx.aui.AuiManager.GetManager(self.GetTopWindow()) aui_manager.UnInit()
def start_recording(self): # check that a dir has been specified if self.txt_outputDir.IsEmpty(): msg = wx.MessageDialog(self, 'Specify the Output Directory', 'Error', wx.OK | wx.ICON_ERROR) msg.ShowModal() == wx.ID_YES msg.Destroy() self.recording = False else: # a directory was specified self.outputDir = self.txt_outputDir.GetValue() self.t = 0 # check if path exists - ie may be saving over data if os.path.exists(self.outputDir): msg = wx.MessageDialog(self, 'Output Directory Exists - Overwrite Data?', 'Yes or No', wx.YES_NO | wx.ICON_QUESTION) result = msg.ShowModal() == wx.ID_YES msg.Destroy() # overwrite the data if result == True: # delete the dir shutil.rmtree(self.outputDir) # re-make dir os.mkdir(self.outputDir) # do not overwrite the data else: # result == False self.recording = False self.txt_outputDir.SetFocus() # no directory so make one else: os.mkdir(self.outputDir)
def update_cron_click(self, e): #make a text file of all the cron jobs cron_text = '' startup_num = cron_list_pnl.startup_cron.GetItemCount() for num in range(0, startup_num): cron_line = '' if cron_list_pnl.startup_cron.GetItemText(num, 1) == 'False': cron_line += '#' cron_line += '@reboot ' + cron_list_pnl.startup_cron.GetItemText(num, 3) # cron_task cron_line += ' ' + cron_list_pnl.startup_cron.GetItemText(num, 4) # cron_extra_args cron_line += ' ' + cron_list_pnl.startup_cron.GetItemText(num, 5) # cron_comment cron_text += cron_line + '\n' repeat_num = cron_list_pnl.repeat_cron.GetItemCount() for num in range(0, repeat_num): cron_line = '' if cron_list_pnl.repeat_cron.GetItemText(num, 1) == 'False': cron_line += '#' cron_line += cron_list_pnl.repeat_cron.GetItemText(num, 2).strip(' ') cron_line += ' ' + cron_list_pnl.repeat_cron.GetItemText(num, 3) # cron_task cron_line += ' ' + cron_list_pnl.repeat_cron.GetItemText(num, 4) # cron_extra_args cron_line += ' ' + cron_list_pnl.repeat_cron.GetItemText(num, 5) # cron_comment cron_text += cron_line + '\n' onetime_num = cron_list_pnl.timed_cron.GetItemCount() for num in range(0, onetime_num): cron_line = '' if cron_list_pnl.timed_cron.GetItemText(num, 1) == 'False': cron_line += '#' cron_line += cron_list_pnl.timed_cron.GetItemText(num, 2).strip(' ') cron_line += ' ' + cron_list_pnl.timed_cron.GetItemText(num, 3) # cron_task cron_line += ' ' + cron_list_pnl.timed_cron.GetItemText(num, 4) # cron_extra_args cron_line += ' ' + cron_list_pnl.timed_cron.GetItemText(num, 5) # cron_comment cron_text += cron_line + '\n' # ask the user if they're sure msg_text = "Update cron to; \n\n" + cron_text mbox = wx.MessageDialog(None, msg_text, "Are you sure?", wx.YES_NO|wx.ICON_QUESTION) sure = mbox.ShowModal() if sure == wx.ID_YES: print "Updating remote cron" # save cron text onto pigrow as text file then import into cron sftp = ssh.open_sftp() try: tempfolder = '/home/pi/Pigrow/temp' sftp.mkdir(tempfolder) except IOError: pass f = sftp.open(tempfolder + '/remotecron.txt', 'w') f.write(cron_text) f.close() try: stdin, stdout, stderr = ssh.exec_command("crontab " + tempfolder + '/remotecron.txt') responce = stdout.read() error = stderr.read() print responce, error except Exception as e: print("this ain't right, it just ain't right! " + str(e)) else: print("Updating cron cancelled") mbox.Destroy() #refresh cron list self.read_cron_click("event")
def on_upgrade(self, event): try: if self.wpkg_dialog.IsShown(): # If dialog is opened already, raise window to top self.wpkg_dialog.Raise() return except AttributeError: # Dialog is not opened yet # Check if Reboot is Pending try: reboot_pending = ReadRebootPendingTime() except WindowsError: dlg_msg = _(u'Registry Error\n\nNo access to necessary registry key.') dlg = wx.MessageDialog(None, dlg_msg, app_name, wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return if reboot_pending and reboot_pending > self.bootup_time: dlg_msg = _(u"Reboot required!\n\n" u"A reboot is required before the system\n" u"can be updated again.\n" u"Reboot now?") dlg = wx.MessageDialog(None, dlg_msg, app_name, wx.YES_NO | wx.YES_DEFAULT | wx.ICON_EXCLAMATION) if dlg.ShowModal() == wx.ID_YES: # Initiate Reboot shutdown(1, time=5, msg=_(u"System will reboot now!")) return else: return elif reboot_pending: SetRebootPendingTime(reset=True) if update_method and update_interval: self.timer.Stop() self.wpkg_dialog = RunWPKGDialog(parent=self, title=_(u'System Update')) self.wpkg_dialog.ShowModal() if self.wpkg_dialog.shutdown_scheduled == True: # Shutdown Scheduled add Cancel Option to Popup Menu self.shutdown_scheduled = True if self.wpkg_dialog.reboot_scheduled == True: # Reboot Scheduled add Cancel Option to Popup Menu self.shutdown_scheduled = True self.reboot_scheduled = True self.wpkg_dialog.Destroy() if update_method and update_interval: self.timer.Start()
def LongTask(self): return_msg = None return_code = None reboot = False # Checking if System is connected through VPN if check_vpn and vpn_connected(arch=arch): dlg_msg = _(u"WPKG-GP Client detected a active VPN Connection using Cisco Anyconnect.\n" u"This could result in slow upgrade progress and updates for the AnyConnect\n" u"Software will be blocked.\n" u"Continue?") dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.YES_NO | wx.YES_DEFAULT | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_NO: # Canceled by user because of active VPN Connection return_msg = 'WPKG process start canceled by user.' # Make translate able? return 400, return_msg, None # LONG TASK is the PipeConnection to the WPKG-GP Windows Service self.running = True msg = 'ExecuteNoReboot' try: pipeHandle = CreateFile("\\\\.\\pipe\\WPKG", GENERIC_READ|GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None) except pywintypes.error, (n, f, e): # print "Error when generating pipe handle: %s" % e # Can't connect to pipe error, probably service not running return_msg = u"Error: WPKG-GP Service not running" return 208, return_msg, None SetNamedPipeHandleState(pipeHandle, PIPE_READMODE_MESSAGE, None, None) WriteFile(pipeHandle, msg) while 1: try: (hr, readmsg) = ReadFile(pipeHandle, 512) out = readmsg[4:].decode('utf-8') #Strip 3 digit status code, decode characters status_code = int(readmsg[:3]) if status_code < 102: # default status code for pipe updates percentage = getPercentage(out) wx.CallAfter(self.update_box.SetValue, out) wx.CallAfter(self.gauge.SetValue, percentage) elif status_code > 300: # reboot necessary reboot = True elif status_code > 200: # possible error return_code = status_code return_msg = out except win32api.error as exc: if exc.winerror == winerror.ERROR_PIPE_BUSY: win32api.Sleep(5000) print 'Pipe Busy Error' continue break return return_code, return_msg, reboot