我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.ICON_ERROR。
def OnQuit(self,event,dbfile): if _plat.startswith('linux'): dlg = wx.MessageDialog(self, 'Really quit?','', wx.OK | wx.CANCEL | wx.ICON_ERROR) val = dlg.ShowModal() dlg.Show() if val == wx.ID_CANCEL: dlg.Destroy() elif val == wx.ID_OK: OKQuit = self.DBQuit(dbfile) if OKQuit == 42: self.Close() elif _plat.startswith('darwin'): pass elif _plat.startswith('win'): OKQuit = self.DBQuit(dbfile) if OKQuit == 42: self.Close() sys.exit()#windows self.Refresh()
def DoLog(self, level, msg, time): if level == wx.LOG_Warning: caption = 'Warning' elif level == wx.LOG_Error: caption = 'Error' else: caption = 'Message' fullMessage = caption + ': ' + msg + '\n' if level == wx.LOG_Error: sys.stderr.write(fullMessage) sys.stderr.flush() for tctrl in self.textCtrls: tctrl.AppendText(fullMessage) if level <= wx.LOG_Warning: dialog = wx.MessageDialog(None, message=msg, caption=caption, style=wx.ICON_ERROR | wx.OK) dialog.ShowModal() dialog.Destroy()
def tellToDoSwipeOrInput(self, evt): operationString = self.OpeartionBox.GetStringSelection() inputC = self.inputContent.GetValue() sX = self.swipeStartX.GetValue() sY = self.swipeStartY.GetValue() eX = self.swipeEndX.GetValue() eY = self.swipeEndY.GetValue() if operationString=="??": if inputC=="": dlg = wx.MessageDialog(self, u"???????", u"????????", wx.OK | wx.ICON_ERROR) if dlg.ShowModal() == wx.ID_OK: dlg.Destroy() else: keyb = self.keyboardType.GetValue() wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg =inputC+"\n"+keyb) else: if sX=="" or sY=="" or eX=="" or eY=="": dlg = wx.MessageDialog(self, u"?????????", u"??????????????????", wx.OK | wx.ICON_ERROR) if dlg.ShowModal() == wx.ID_OK: dlg.Destroy() else: wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg ="??\n%d\n%d\n%d\n%d" % (sX,sY,eX,eY))
def on_transform_button_click(self, event): slice_startswith = self.slice_text.GetValue() template_path = self.get_template_path() response_body = self.GetParent().get_response_content() try: handler = Request2Doc() handler.set_slice_startswith(slice_startswith) handler.set_response_body(response_body) if not handler.get_response_data(): return wx.MessageDialog(None, u'Response body is not legal format', u"Information", wx.OK | wx.ICON_INFORMATION).ShowModal() self.GetParent().set_document_content(handler.render_string(template_path)) except Exception, e: return wx.MessageDialog(None, traceback.format_exc(), u"Exception", wx.OK | wx.ICON_ERROR).ShowModal()
def download_complete(self, errors): if self.progress_dialog: logger.info("Beginning download") self.downloader.join() if errors: done_string = "Songs downloaded with {errors} error(s)".format(errors=len(errors)) else: done_string = "All songs were downloaded succesfully!" logger.info(done_string) done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam") done_message.ShowModal() done_message.Destroy() if errors: errors = '\n'.join(errors) logger.critical("Error downloading these these URLs:\n{errors}".format(errors=errors)) error_dialog = wx.MessageDialog(parent=self, message="The following URLs caused errors\n" + errors, caption="Download Error!", style=wx.ICON_ERROR) error_dialog.ShowModal() error_dialog.Destroy() self.progress_dialog.Destroy() self.Destroy() wx.CallAfter(self.parent.convert, event=None, in_dir=self.out_dir.GetPath())
def convert_complete(self, errors): if self.progress_dialog: self.converter.join() if errors: done_string = "Songs converted with {errors} error(s)".format(errors=len(errors)) else: done_string = "All songs were converted succesfully!" done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam") done_message.ToggleWindowStyle(wx.STAY_ON_TOP) done_message.ShowModal() done_message.Destroy() if errors: errors = '\n'.join(errors) error_dialog = wx.MessageDialog(parent=self, message="The following files caused errors\n" + errors, caption="Conversion Error!", style=wx.OK | wx.ICON_ERROR) error_dialog.ShowModal() error_dialog.Destroy() logger.critical("Error converting these files\n{errors}".format(errors=errors)) logger.info(done_string) wx.CallAfter(self.progress_dialog.Destroy)
def OnGenerateProgramMenu(self, event): dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Controler.GetProgramFilePath(), _("ST files (*.st)|*.st|All files|*.*"), wx.SAVE | wx.CHANGE_DIR) if dialog.ShowModal() == wx.ID_OK: filepath = dialog.GetPath() message_text = "" header, icon = _("Done"), wx.ICON_INFORMATION if os.path.isdir(os.path.dirname(filepath)): program, errors, warnings = self.Controler.GenerateProgram(filepath) message_text += "".join([_("warning: %s\n") % warning for warning in warnings]) if len(errors) > 0: message_text += "".join([_("error: %s\n") % error for error in errors]) message_text += _("Can't generate program to file %s!") % filepath header, icon = _("Error"), wx.ICON_ERROR else: message_text += _("Program was successfully generated!") else: message_text += _("\"%s\" is not a valid folder!") % os.path.dirname(filepath) header, icon = _("Error"), wx.ICON_ERROR message = wx.MessageDialog(self, message_text, header, wx.OK | icon) message.ShowModal() message.Destroy() dialog.Destroy()
def GetDimensions(self): message = None dimensions_list = [] dimension_strings = self.Dimensions.GetStrings() if len(dimension_strings) == 0: message = _("Empty dimension isn't allowed.") for dimensions in dimension_strings: result = DIMENSION_MODEL.match(dimensions) if result is None: message = _("\"%s\" value isn't a valid array dimension!") % dimensions break bounds = result.groups() if int(bounds[0]) >= int(bounds[1]): message = _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.") % dimensions break dimensions_list.append(bounds) if message is not None: dlg = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return None return dimensions_list
def OnOK(self, event): message = None step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() if step_name == "": message = _("You must type a name!") elif not TestIdentifier(step_name): message = _("\"%s\" is not a valid identifier!") % step_name elif step_name.upper() in IEC_KEYWORDS: message = _("\"%s\" is a keyword. It can't be used!") % step_name elif step_name.upper() in self.PouNames: message = _("A POU named \"%s\" already exists!") % step_name if message is not None: dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() else: self.EndModal(wx.ID_OK) event.Skip()
def OnOK(self, event): message = None step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() if step_name == "": message = _("You must type a name!") elif not TestIdentifier(step_name): message = _("\"%s\" is not a valid identifier!") % step_name elif step_name.upper() in IEC_KEYWORDS: message = _("\"%s\" is a keyword. It can't be used!") % step_name elif step_name.upper() in self.PouNames: message = _("A POU named \"%s\" already exists!") % step_name elif step_name.upper() in self.Variables: message = _("A variable with \"%s\" as name already exists in this pou!") % step_name elif step_name.upper() in self.StepNames: message = _("\"%s\" step already exists!") % step_name if message is not None: dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() else: self.EndModal(wx.ID_OK) event.Skip()
def OnTreeEndLabelEdit(self, event): new_name = event.GetLabel() if new_name != "": old_filepath = self.GetPath(event.GetItem()) new_filepath = os.path.join(os.path.split(old_filepath)[0], new_name) if new_filepath != old_filepath: if not os.path.exists(new_filepath): os.rename(old_filepath, new_filepath) event.Skip() else: message = wx.MessageDialog(self, _("File '%s' already exists!") % new_name, _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy() event.Veto() else: event.Skip()
def ShowMessage(self, message): """ Show error message in Error Dialog @param message: Error message to display """ dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() # ------------------------------------------------------------------------------- # Debug Variable Graphic Viewer Class # -------------------------------------------------------------------------------
def ShowMessage(self, message): """ Show error message in Error Dialog @param message: Error message to display """ dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() # ------------------------------------------------------------------------------- # Debug Variable Text Viewer Class # -------------------------------------------------------------------------------
def OnEnumeratedValueEndEdit(self, event): text = event.GetText() values = self.EnumeratedValues.GetStrings() index = event.GetIndex() if index >= len(values) or values[index].upper() != text.upper(): if text.upper() in [value.upper() for value in values]: message = wx.MessageDialog(self, _("\"%s\" value already defined!") % text, _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy() event.Veto() elif text.upper() in IEC_KEYWORDS: message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!") % text, _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy() else: initial_selected = None if index < len(values) and self.EnumeratedInitialValue.GetStringSelection() == values[index]: initial_selected = text wx.CallAfter(self.RefreshEnumeratedValues, initial_selected) wx.CallAfter(self.RefreshTypeInfos) event.Skip() else: event.Skip()
def Paste(self, bbx=None): if not self.Debug: element = self.ParentWindow.GetCopyBuffer() if bbx is None: mouse_pos = self.Editor.ScreenToClient(wx.GetMousePosition()) middle = wx.Rect(0, 0, *self.Editor.GetClientSize()).InsideXY(mouse_pos.x, mouse_pos.y) if middle: x, y = self.CalcUnscrolledPosition(mouse_pos.x, mouse_pos.y) else: x, y = self.CalcUnscrolledPosition(0, 0) new_pos = [int(x / self.ViewScale[0]), int(y / self.ViewScale[1])] else: middle = True new_pos = [bbx.x, bbx.y] result = self.Controler.PasteEditedElementInstances(self.TagName, element, new_pos, middle, self.Debug) if not isinstance(result, (StringType, UnicodeType)): self.RefreshBuffer() self.RefreshView(selection=result) self.RefreshVariablePanel() self.ParentWindow.RefreshPouInstanceVariablesPanel() else: message = wx.MessageDialog(self.Editor, result, "Error", wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy()
def validate_email(self): self.CHECK_LIST_ITEMS=[] sending_numbers=self.text_ctrl_selected_email.Value sending_numbers=sending_numbers.split(";") for email in sending_numbers: print email if not email: continue if self.V.validate_email(email)[0]: self.CHECK_LIST_ITEMS.append(email) else: #msg=email+" is invalid email id. Either edit or delete it to continue!" #dlg = wx.MessageDialog(self, msg, 'Error',wx.OK | wx.ICON_ERROR) #dlg.ShowModal() #dlg.Destroy() return 0 return True
def validate_pass(self): if not self.UO.Login_Check(self.combo_box_1.Value,self.text_ctrl_1.Value): return False if len(self.text_ctrl_2.Value)<5: dlg = wx.MessageDialog(self, 'Password must be of at least five characters', '',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return False if self.text_ctrl_2.Value!=self.text_ctrl_3.Value: dlg = wx.MessageDialog(self, 'Passwords do not match', '',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return False return True
def on_save(self, event): # wxGlade: institution.<event_handler> try: self.DB.Set_School_Name(self.text_ctrl_name.Value) self.DB.Set_School_Code(self.text_ctrl_code.Value) self.DB.Set_School_Email(self.text_ctrl_email.Value) self.DB.Set_School_Contact(self.text_ctrl_phone.Value) self.DB.Set_School_DEO(self.text_ctrl_deo.Value) dlg = wx.MessageDialog(self, 'Successfully Saved', '',wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() except: dlg = wx.MessageDialog(self, 'Could not save some values', '',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() self.Close(True) event.Skip()
def validate_mobile(self): self.SENDING_LIST=[] V=validate() sending_numbers=self.text_ctrl_selected_contacts.Value sending_numbers=sending_numbers.split(";") for mobile in sending_numbers: if not mobile: continue if V.validate_mobile(mobile)[0]: self.SENDING_LIST.append(mobile) else: msg=mobile+" is invalid mobile number. Either edit it or delete to continue!" dlg = wx.MessageDialog(self, msg, 'Error',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return 0 return True
def Validate_Adm_No(self,value): if not value.isdigit() and value!="": '''dlg = wx.MessageDialog(None, 'Admission No should be integer', '',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() ''' return 0 else: # if admission no already exists if self.DB.Admission_Exists(value)!=False: print 'Admission No: ',value,' is already allotted to', self.DB.Admission_Exists(value)[1] return 0 return 1
def OnSave(self, event): # wxGlade: MyFrame2.<event_handler> CE=[self.ce_1,self.ce_2,self.ce_3,self.ce_4,self.ce_5,self.ce_6,self.ce_7,self.ce_8,self.ce_9,self.ce_10,self.ce_11,self.ce_12,self.ce_13] TE=[self.te_1,self.te_2,self.te_3,self.te_4,self.te_5,self.te_6,self.te_7,self.te_8,self.te_9,self.te_10,self.te_11,self.te_12,self.te_13] try: for i in range(13): if self.YEAR=='Select' or self.STD=='Select': break else: index=i#in deb oper Get_CE_CE() index for work exp starts at 12 if i>=10: index+=2 self.DB.Set_CE_TE(self.YEAR,self.STD,index,CE[i].Value,TE[i].Value) dlg = wx.MessageDialog(self, 'Successfully Saved', '',wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() except: dlg = wx.MessageDialog(self, 'Error! Could not Save', '',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() event.Skip()
def place(self, e): if not hasattr(self, "brackets"): errortext = "Make bracket before doing that" w = wx.MessageDialog(self.parent, errortext, "Error", wx.ICON_ERROR) w.ShowModal() w.Destroy() return placel = bracketfuncs.placing(self.brackets) d = wx.Dialog(None) d.SetTitle("Results") a = wx.TextCtrl(d, style=wx.TE_MULTILINE) a.SetEditable(False) ptxt = "" for p in placel: if not p.isbye(): ptxt += str(placel[p]) + ". " + p.tag + "\n" a.SetValue(ptxt) d.SetSize((250, 320)) d.Show(True)
def OnAdd(self, evt): dialog = wx.TextEntryDialog(self, "Enter name:", "Add", style = wx.OK | wx.CANCEL) dialog.Centre(wx.BOTH) if dialog.ShowModal() == wx.ID_OK: name = dialog.GetValue() if name not in ("CURRENT", ) and name not in self.all_hosts: fpath = os.path.join(DataPath, name) shutil.copy(os.path.join(DataPath, "default"), fpath) call_editor(fpath) self.all_hosts.append(name) self.combo_box_1.AppendItems([name]) else: msg_dialog = wx.MessageDialog(self, "Failed to create \"%s\".\nFile already exists." % name, 'Failed to create "%s"' % name, wx.OK | wx.ICON_ERROR) msg_dialog.Centre(wx.BOTH) msg_dialog.ShowModal() msg_dialog.Destroy() dialog.Destroy()
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 OnInit(self): """ Run automatically when the wxPython application starts. """ self.frame = wx.Frame(None, title="PyUpdater wxPython Demo") self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame) self.frame.SetSize(wx.Size(400, 100)) self.statusBar = wx.StatusBar(self.frame) self.statusBar.SetStatusText(self.status) self.frame.SetStatusBar(self.statusBar) self.panel = wx.Panel(self.frame) self.sizer = wx.BoxSizer() self.sizer.Add( wx.StaticText(self.frame, label="Version %s" % __version__)) self.panel.SetSizerAndFit(self.sizer) self.frame.Show() if hasattr(sys, "frozen") and \ not os.environ.get('PYUPDATER_FILESERVER_DIR'): dlg = wx.MessageDialog( self.frame, "The PYUPDATER_FILESERVER_DIR environment variable " "is not set!", "PyUpdaterWxDemo File Server Error", wx.OK | wx.ICON_ERROR) dlg.ShowModal() return True
def TakeSnapshot(self,e,args): logging.exception('CAPTURE') if self.camset == 1: self.framlog += 1 #print(self.camhero)#DEBUG vidcap = vlc.libvlc_video_take_snapshot(self.player,0,os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png'),0,0) self.cur.execute('INSERT INTO Timeline VALUES(Null,?,?)', (str(self.framlog).zfill(3)+'.png',0)) # add graphically to timeline img = self.MakeThumbnail(os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png'), self.thumbsize) self.imageCtrl = wx.StaticBitmap(self.panel3, wx.ID_ANY, wx.BitmapFromImage(img),name=str(self.framlog).zfill(3)+'.png') self.imageCtrl.SetBitmap(wx.BitmapFromImage(img)) self.imageCtrl.Bind( wx.EVT_LEFT_DOWN, self.OnLeftClick ) self.imageCtrl.Bind( wx.EVT_LEFT_UP, self.OnLeftRelease ) logging.exception(self.imageCtrl.GetId() ) self.hbox2.Add( self.imageCtrl, 0, wx.ALL, 5 ) # scroll right 100% to get close to new frame self.panel3.Scroll(self.thumbsize,0) self.Layout() # draw new frame self.hbox2.Layout() self.panel3.Refresh() # scroll WAY right again to show frame self.panel3.Scroll(200,0) # send the shot to onion skin img = os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png') self.OnionSkin(img) logging.exception(self.framlog) else: dlg = wx.MessageDialog(self, 'Please select your camera first.','',wx.OK | wx.ICON_ERROR) val = dlg.ShowModal() if val == wx.ID_OK: dlg.Destroy() if val == wx.ID_CANCEL: dlg.Destroy() self.player.play() self.brec.SetBitmapLabel(self.brecicon)
def on_ok(self, e): self.session_file_path = self.session_picker.GetPath() if not self.session_file_path: wx.MessageBox(_("Please specify the Current Fest file."), "No Fest File", wx.OK | wx.ICON_ERROR, self) return self.config[Config.PROJECTOR_SCREEN] = self.screens_combobox.GetSelection() self.config[Config.FILENAME_RE] = self.filename_re.GetValue() self.config[Config.BG_TRACKS_DIR] = self.bg_tracks.GetPath() self.config[Config.BG_ZAD_PATH] = self.bg_zad.GetPath() self.config[Config.FILES_DIRS] = [picker.GetPath() for picker in self.dir_pickers] self.EndModal(e.Id)
def switch_device(self, device, currently): switch_path = "/home/" + pi_link_pnl.target_user + "/Pigrow/scripts/switches/" if currently == "ON": switch_command = switch_path + device + "_off.py" future_state = "OFF" elif currently == "OFF": switch_command = switch_path + device + "_on.py" future_state = "ON" else: switch_command = "ERROR" #if error show error message if not switch_command == "ERROR": #make dialogue box to ask if should switch the device d = wx.MessageDialog( self, "Are you sure you want to switch " + device + " to the " + future_state + " poisition?\n\n\n " + "Note: automated control scripts might " + "\n switch this " + currently + " again " + "\n if thier trigger conditions are met. " , "Switch " + device + " " + future_state + "?" , wx.OK | wx.CANCEL | wx.ICON_QUESTION) answer = d.ShowModal() d.Destroy() #if user said ok then switch device if (answer == wx.ID_OK): out, error = MainApp.localfiles_ctrl_pannel.run_on_pi(switch_command) print out # shows box with switch info from pigrow if not error == "": print error config_ctrl_pnl.currently_toedit = future_state #for if toggling within the dialog box self.update_box_text() config_ctrl_pnl.currently_new = future_state config_ctrl_pnl.device_new = device config_ctrl_pnl.gpio_new = config_ctrl_pnl.gpio_toedit config_ctrl_pnl.wiring_new = config_ctrl_pnl.wiring_toedit else: d = wx.MessageDialog(self, "Error, current state not determined\n You must upload the settings to the pigrow before switching the device", "Error", wx.OK | wx.ICON_ERROR) answer = d.ShowModal() d.Destroy() return "ERROR"
def click_search_answer(self, event=None): page_source_code = self.web_panel.get_page_source_code() logic_controller = LogicController(parent=self, page_source_code=page_source_code, enable_web_copy=True) parse_answers_result = logic_controller.get_parse_page_status() logging.debug("result:%s" % str(parse_answers_result)) if parse_answers_result: self.show_and_select_answer( answer_choice_group_formated=logic_controller.get_answer_choice_group_formated(), auto_select_answer_script=logic_controller.get_auto_select_answer_script()) self.show_on_statusbar(message=u"?????") self.show_dialog(messgage=_HAS_FUND_MESSAGE, caption=u"????(?'?'?)", style=wx.OK) else: self.show_on_statusbar(message=logic_controller.get_error_message()) # u"?????????" self.show_dialog(messgage=_NOT_FIND_MESSAGE, caption=u"Error", style=wx.ICON_ERROR)
def DoSwipeOrInput(self, msg): global recordStatus global treeDic global recordTimeDelay if treeDic!=None: if recordStatus=="?": if "??" in msg: d = msg.replace("??\n", "").split("\n") print("?????,", "???: ",d) os.system("adb shell input swipe %d %d %d %d" % (int(d[0]), int(d[1]),int(d[2]),int(d[3]))) dlg = MessageDialog('??????????(?????%d?)' % recordTimeDelay, '??') wx.CallLater(recordTimeDelay*1000, dlg.Destroy) dlg.ShowModal() getNewScreenShotAndDomFileThread() else: c = msg.split("\n")[0] kT = msg.split("\n")[1] print("?????,", "???",c) if c!='': if kT == "ADB": os.system("adb shell am broadcast -a ADB_INPUT_TEXT --es msg '%s'" %c) else: os.system("adb shell input text '%s'" %c) dlg = MessageDialog('??????????(?????%d?)' % recordTimeDelay, '??') wx.CallLater(recordTimeDelay*1000, dlg.Destroy) dlg.ShowModal() getNewScreenShotAndDomFileThread() else: dlg = wx.MessageDialog(self, u"???????", u"????????", wx.OK | wx.ICON_ERROR) if dlg.ShowModal() == wx.ID_OK: dlg.Destroy() else: msg = "????????????????" print(msg) wx.CallAfter(pub.sendMessage, "update", msg=msg) else: msg = "?????????????" print(msg) wx.CallAfter(pub.sendMessage, "update", msg=msg)
def on_request_transform_button_click(self, event): url = self.url_text.GetValue() method = self.method_choice.GetStringSelection() params_value = self.post_params_text.GetValue() headers_value = self.headers_text.GetValue() slice_startswith = self.slice_text.GetValue() template_path = self.get_template_path() request_forms = {k: v[0] for k, v in urlparse.parse_qs(params_value).items()} headers = headers_value.split('\n') handler = Request2Doc(url, method, request_forms) if slice_startswith: handler.set_slice_startswith(slice_startswith) if headers: handler.set_headers(headers) try: if not handler.validate(): return wx.MessageDialog(None, handler.error_message(), u"Info", wx.OK | wx.ICON_INFORMATION).ShowModal() handler.request() if not handler.get_response_data(): return wx.MessageDialog(None, u'Response body is not legal format', u"Information", wx.OK | wx.ICON_INFORMATION).ShowModal() res = handler.render_string(template_path) self.GetParent().set_response_content(json.dumps(handler.get_response_data(), indent=2)) self.GetParent().set_document_content(res) except Exception, e: return wx.MessageDialog(None, traceback.format_exc(), u"Exception", wx.OK | wx.ICON_ERROR).ShowModal()
def wrap_exceptions(func): """Wraps a function with an "exception hook" for threads. Args: func (function): The function to wrap. Returns: function: The wrapped function """ @wraps(func) def wrapper(*args, **kwargs): # args[0] = when wrapping a class method. (IT BETTER BE. WHYDOISUCKATPROGRAMMINGOHGOD) # This should really only be used on threads (main thread has a sys.excepthook) try: return func(*args, **kwargs) except (SystemExit, KeyboardInterrupt): raise except Exception: if isinstance(args[0], wx.TopLevelWindow): parent = args[0] elif hasattr(args[0], "parent") and isinstance(args[0].parent, wx.TopLevelWindow): parent = args[0].parent else: parent = wx.GetApp().GetTopWindow() error_message = ''.join(traceback.format_exc()) error_dialog = wx.MessageDialog(parent=parent, message="An error has occured\n\n" + error_message, caption="Error!", style=wx.OK | wx.ICON_ERROR) error_dialog.RequestUserAttention() error_dialog.ShowModal() error_dialog.Destroy() logger.critical(error_message) raise return wrapper
def addonUpdateCheck(autoCheck=False): global progressDialog config.conf["wintenApps"]["updateCheckTime"] = int(time.time()) + config.conf["wintenApps"]["updateCheckTimeInterval"] * addonUpdateCheckInterval try: info = checkForAddonUpdate() except: log.debugWarning("Error checking for update", exc_info=True) if not autoCheck: wx.CallAfter(progressDialog.done) progressDialog = None # Translators: Error text shown when add-on update check fails. wx.CallAfter(gui.messageBox, _("Error checking for update."), # Translators: Title of the dialog shown when add-on update check fails. _("Windows 10 App Essentials update"), wx.ICON_ERROR) return if not autoCheck: wx.CallAfter(progressDialog.done) progressDialog = None if info is None: if not autoCheck: # Translators: Presented when no add-on update is available. wx.CallAfter(gui.messageBox, _("No add-on update available."), # Translators: Title of the dialog presented when no add-on update is available. _("Windows 10 App Essentials update")) return else: # Translators: Text shown if an add-on update is available. checkMessage = _("Windows 10 App Essentials {newVersion} is available. Would you like to update?").format(newVersion = info["newVersion"]) # Translators: Title of the add-on update check dialog. wx.CallAfter(getUpdateResponse, checkMessage, _("Windows 10 App Essentials update"), info["path"])
def _error(self): self._stopped() gui.messageBox( # Translators: A message indicating that an error occurred while downloading an update to NVDA. _("Error downloading add-on update."), # Translators: The title of a dialog indicating that an error occurred while downloading an update to NVDA. _("Error"), wx.OK | wx.ICON_ERROR)
def InitUI(self): self.panel = wx.Panel(self, wx.ID_ANY) sizer = wx.BoxSizer(wx.VERTICAL) self.html = help = wx.html.HtmlWindow(self.panel, -1, style=wx.NO_BORDER) # http://wxpython-users.1045709.n5.nabble.com/Open-a-URL-with-the-default-browser-from-an-HtmlWindow-td2326349.html # Bind LINK Click Event to own Function help.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) #import codecs #file = codecs.open(self.help, "r", "utf-8") try: file = open(self.help, "r") except IOError: dlgmsg = u"File not found: \"{}\"".format(self.help) dlg = wx.MessageDialog(None, dlgmsg, "WPKG-GP Client", wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() self.Destroy() else: test = file.read().decode("utf-8") html = markdown2.markdown(test, extras=["tables"]) html = '<body bgcolor="#f0f0f5">' + html #print html help.SetPage(html) sizer.Add(help, 1, wx.EXPAND) self.panel.SetSizerAndFit(sizer) self.Bind(wx.EVT_CLOSE, self.OnClose)
def update_check_done(self, result): # Update check function ended r = result.get() self.checking_updates = False if isinstance(r, basestring): # Error returned self.updates_available = False if self.upd_error_count < 2 and not self.show_no_updates: # only display update errors on automatic check after the third error in a row self.upd_error_count += 1 else: error_str = _(u"Could not load updates:") + "\n" + r self.ShowBalloon(title=_(u'Update Error'), text=error_str, msec=20*1000, flags=wx.ICON_ERROR) # reset update error counter self.upd_error_count = 0 elif r: self.upd_error_count = 0 action_dict = {'update': _(u'UPD:') + '\t', 'install': _(u'NEW:') + '\t', 'remove': _(u'REM:') + '\t', 'downgrade': _(u'DOW:') + '\t'} # Updates Found self.updates_available = True text = '' for action, name, version in r: text += action_dict[action] + name + ', v. ' + version + '\n' self.ShowBalloon(title=_(u"Update(s) available:"), text=text, msec=20*1000, flags=wx.ICON_INFORMATION) else: # No Updates Found self.upd_error_count = 0 self.updates_available = False if self.show_no_updates: self.ShowBalloon(title=_(u"No Updates"), text=" ", msec=20 * 1000, flags=wx.ICON_INFORMATION) self.show_no_updates = False
def OnAddClick(self, evt): with AddCriteriumDialog(self) as entryDialog: if entryDialog.ShowModal() != wx.ID_OK: return identifier = entryDialog.identifierTextCtrl.GetValue() if not identifier: return for index, criterium in enumerate(self.criteriums): if identifier == criterium.identifier: # Translators: An error reported in the Criterium Pronunciation dialog when adding a criterium that is already present. gui.messageBox(_('Criterium "%s" is already present.') % identifier, _("Error"), wx.OK | wx.ICON_ERROR) self.criteriumsList.Select(index) self.criteriumsList.Focus(index) self.criteriumsList.SetFocus() return addedCriterium = characterProcessing.SpeechCriterium(identifier) try: del self.pendingRemovals[identifier] except KeyError: pass addedCriterium.displayName = identifier addedCriterium.replacement = "" addedCriterium.level = characterProcessing.SYMLVL_ALL addedCriterium.preserve = characterProcessing.SYMPRES_NEVER self.criteriums.append(addedCriterium) item = self.criteriumsList.Append((addedCriterium.displayName,)) self.updateListItem(item, addedCriterium) self.criteriumsList.Select(item) self.criteriumsList.Focus(item) self.criteriumsList.SetFocus()
def OnOK(self, event): selected = self.ValuesLibrary.GetSelection() if not selected.IsOk() or self.ValuesLibrary.GetPyData(selected) is None: message = wx.MessageDialog(self, _("No valid value selected!"), _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy() else: self.EndModal(wx.ID_OK)
def OnOK(self, event): values = self.ProjectProperties.GetValues() error = [] for param, name in [("projectName", _("Project Name")), ("productName", _("Product Name")), ("productVersion", _("Product Version")), ("companyName", _("Company Name"))]: if values[param] == "": error.append(name) if len(error) > 0: text = "" for i, item in enumerate(error): if i == 0: text += item elif i == len(error) - 1: text += _(" and %s") % item else: text += ", %s" % item dialog = wx.MessageDialog( self, _("Form isn't complete. %s must be filled!") % text, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() else: self.EndModal(wx.ID_OK)
def OnOK(self, event): message = None value = self.ValueTextCtrl.GetValue() if value == "": message = _("You must type a value!") elif GetTypeValue[self.IEC_Type](value) is None: message = _("Invalid value \"{a1}\" for \"{a2}\" variable!").format(a1=value, a2=self.IEC_Type) if message is not None: dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() else: self.EndModal(wx.ID_OK) event.Skip()
def ShowErrorMessage(self, message): """ Show an error message dialog over this dialog @param message: Error message to display """ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy()
def OnOK(self, event): selected = self.LocationsTree.GetSelection() var_infos = None if selected.IsOk(): var_infos = self.LocationsTree.GetPyData(selected) if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]: dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() else: self.EndModal(wx.ID_OK)
def OnOK(self, event): error = [] transition_name = self.TransitionName.GetValue() if self.TransitionName.GetValue() == "": error.append(_("Transition Name")) if self.Language.GetSelection() == -1: error.append(_("Language")) message = None if len(error) > 0: text = "" for i, item in enumerate(error): if i == 0: text += item elif i == len(error) - 1: text += _(" and %s") % item else: text += _(", %s") % item message = _("Form isn't complete. %s must be filled!") % text elif not TestIdentifier(transition_name): message = _("\"%s\" is not a valid identifier!") % transition_name elif transition_name.upper() in IEC_KEYWORDS: message = _("\"%s\" is a keyword. It can't be used!") % transition_name elif transition_name.upper() in self.PouNames: message = _("A POU named \"%s\" already exists!") % transition_name elif transition_name.upper() in self.PouElementNames: message = _("\"%s\" element for this pou already exists!") % transition_name if message is not None: dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() else: self.EndModal(wx.ID_OK)
def GetControlValueTestFunction(self, control): def OnValueChanged(event): try: value = float(control.GetValue()) except ValueError, e: message = wx.MessageDialog(self, _("Invalid value!\nYou must fill a numeric value."), _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy() event.Skip() self.OnCloseDialog() return OnValueChanged
def OnFindButton(self, event): message = None infos = { "find_pattern": self.Pattern.GetValue(), "case_sensitive": self.CaseSensitive.GetValue(), "regular_expression": self.RegularExpression.GetValue(), } if self.WholeProject.GetValue(): infos["filter"] = "all" elif self.OnlyElements.GetValue(): infos["filter"] = [] for index, (name, label) in enumerate(GetElementsChoices()): if self.ElementsList.IsChecked(index): infos["filter"].append(name) if self.infosPrev != infos: try: self.criteria = infos CompilePattern(self.criteria) self.infosPrev = infos except Exception: self.criteria.clear() message = _("Syntax error in regular expression of pattern to search!") if message is not None: dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() else: self.EndModal(wx.ID_OK)
def ShowErrorMessage(self, message): """Function displaying an Error dialog in editor. :param message: The message to display. """ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy()
def ShowMessage(self, message): message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy() # ------------------------------------------------------------------------------- # Variable Panel # -------------------------------------------------------------------------------
def ShowMessage(self, message): """ Show error message in Error Dialog @param message: Error message to display """ dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy()
def ShowErrorMessage(self, message): dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy()
def ShowMessage(self, message): message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) message.ShowModal() message.Destroy()