我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.MessageDialog()。
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 do_input(Class, parent, title, fields, data): dlg = Class(parent, -1, title, size=(350, 200), style=wx.DEFAULT_DIALOG_STYLE, # & ~wx.CLOSE_BOX, fields=fields, data=data ) dlg.CenterOnScreen() while 1: val = dlg.ShowModal() if val == wx.ID_OK: values = {} for field in fields: try: values[field] = eval(dlg.textctrls[field].GetValue()) except Exception, e: msg = wx.MessageDialog(parent, unicode(e), "Error in field %s" % field, wx.OK | wx.ICON_INFORMATION ) msg.ShowModal() msg.Destroy() break else: return dict([(field, values[field]) for field in fields]) else: return None
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 onsoftreboot(self, event): fila = self.listadoVM for i in range(len(fila)): if logger != None: logger.info(fila[i]) # El 9 elemento es el UUID if logger != None: logger.info (fila[8]) #Pedimos confirmacion del reset de la mv con ventana dialogo dlg_reset = wx.MessageDialog(self, "Estas a punto de reiniciar \n " + fila[1] + " ", "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION) result = dlg_reset.ShowModal() dlg_reset.Destroy() if result == wx.ID_OK: vm = conexion.searchIndex.FindByUuid(None,fila[8], True) if vm is not None: if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState)) TASK = vm.RebootGuest() #Este da error tasks.wait_for_tasks(conexion, [TASK]) if logger != None: logger.info("Soft reboot its done.")
def onsoftPowerOff(self, event): fila = self.listadoVM for i in range(len(fila)): if logger != None: logger.info(fila[i]) # El 9 elemento es el UUID if logger != None: logger.info (fila[8]) #Pedimos confirmacion del reset de la mv con ventana dialogo dlg_reset = wx.MessageDialog(self, "Estas a punto de Soft Apagar \n " + fila[1] + " ", "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION) result = dlg_reset.ShowModal() dlg_reset.Destroy() if result == wx.ID_OK: vm = conexion.searchIndex.FindByUuid(None,fila[8], True) if vm is not None: if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState)) TASK = vm.ShutdownGuest() #Este da error tasks.wait_for_tasks(conexion, [TASK]) if logger != None: logger.info("Soft poweroff its done.") # Reiniciamos el ordenador seleccionado en el menu contextual
def onreboot(self, event): fila = self.listadoVM for i in range(len(fila)): if logger != None: logger.info(fila[i]) # El 9 elemento es el UUID if logger != None: logger.info (fila[8]) #Pedimos confirmacion del reset de la mv con ventana dialogo dlg_reset = wx.MessageDialog(self, "Estas a punto de reiniciar \n " + fila[1] + " ", "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION) result = dlg_reset.ShowModal() dlg_reset.Destroy() if result == wx.ID_OK: vm = conexion.searchIndex.FindByUuid(None,fila[8], True) if vm is not None: if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState)) TASK = vm.ResetVM_Task() tasks.wait_for_tasks(conexion, [TASK]) if logger != None: logger.info("reboot its done.")
def onpower_on(self, event): fila = self.listadoVM for i in range(len(fila)): if logger != None: logger.info(fila[i]) # El 9 elemento es el UUID if logger != None: logger.info (fila[8]) #Pedimos confirmacion del poweron de la mv con ventana dialogo dlg_reset = wx.MessageDialog(self, "Estas a punto de iniciar \n " + fila[1] + "\nAhora esta: " + fila[3], "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION) result = dlg_reset.ShowModal() dlg_reset.Destroy() if result == wx.ID_OK: vm = conexion.searchIndex.FindByUuid(None,fila[8], True) if vm is not None and not vm.runtime.powerState == 'poweredOn': if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState)) TASK = vm.PowerOn() tasks.wait_for_tasks(conexion, [TASK]) if logger != None: logger.info("Power ON its done.")
def onpowerOff(self, event): fila = self.listadoVM for i in range(len(fila)): if logger != None: logger.info(fila[i]) # El 9 elemento es el UUID if logger != None: logger.info (fila[8]) #Pedimos confirmacion del reset de la mv con ventana dialogo dlg_reset = wx.MessageDialog(self, "Estas a punto de Apagar \n " + fila[1] + " ", "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION) result = dlg_reset.ShowModal() dlg_reset.Destroy() if result == wx.ID_OK: vm = conexion.searchIndex.FindByUuid(None,fila[8], True) if vm is not None and not vm.runtime.powerState == 'poweredOff': if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState)) TASK = vm.PowerOff() tasks.wait_for_tasks(conexion, [TASK]) if logger != None: logger.info("Power OFF its done.")
def PrintPreview(self): """Print-preview current plot.""" printout = PlotPrintout(self) printout2 = PlotPrintout(self) self.preview = wx.PrintPreview(printout, printout2, self.print_data) if not self.preview.IsOk(): wx.MessageDialog(self, "Print Preview failed.\n" "Check that default printer is configured\n", "Print error", wx.OK | wx.CENTRE).ShowModal() self.preview.SetZoom(40) # search up tree to find frame instance frameInst = self while not isinstance(frameInst, wx.Frame): frameInst = frameInst.GetParent() frame = wx.PreviewFrame(self.preview, frameInst, "Preview") frame.Initialize() frame.SetPosition(self.GetPosition()) frame.SetSize((600, 550)) frame.Centre(wx.BOTH) frame.Show(True)
def OnHelp(self,e): dlg = wx.MessageDialog(self, "Bonsu will attempt to open the"+os.linesep+"documentation with your default"+os.linesep+"browser. Continue?","Confirm Open", wx.OK|wx.CANCEL|wx.ICON_QUESTION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_OK: path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'docs', 'bonsu.html') if sys.platform.startswith('win'): os.startfile(path) elif sys.platform.startswith('darwin'): from subprocess import Popen Popen(['open', path]) else: try: from subprocess import Popen Popen(['xdg-open', path]) except: pass
def OnConnect(self,event): Username = self.username.GetValue() Password = self.pwd.GetValue() mac = get.get_mac_address() self.MAC=mac ip = get.Get_local_ip() self.IP=ip upnet_net = packet.generate_upnet(mac, ip, Username, Password) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) hosts = '210.45.194.10' status,message= connect.upnet(sock, upnet_net, hosts,self.getsession) if status == 0: msgbox = wx.MessageDialog(None, "",message,wx.OK) msgbox.ShowModal() frame=MainFrame() frame.Show() else: self.connect.Disable() self.disconnect.Enable() self.username.SetEditable(False) self.pwd.SetEditable(False) wx.MessageBox(u'??????',message) self.SetStatusText(u"????") self.OnStartThread()
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 update_check(parent): """Check for updates using the GitHub API Args: parent (wx.Window): The parent window (for the message dialog) Returns: None """ r = requests.get('https://api.github.com/repos/10se1ucgo/pyjam/releases/latest') if not r.ok: return new = r.json()['tag_name'] try: if StrictVersion(__version__) < StrictVersion(new.lstrip('v')): info = wx.MessageDialog(parent, message="pyjam {v} is now available!\nGo to download page?".format(v=new), caption="pyjam Update", style=wx.OK | wx.CANCEL | wx.ICON_INFORMATION) if info.ShowModal() == wx.ID_OK: webbrowser.open_new_tab(r.json()['html_url']) info.Destroy() except ValueError: pass
def on_ok(self, event): songs = yt_extract(self.audio_links.GetValue().split(',')) if not songs: error = wx.MessageDialog(parent=self, message="Invalid/Unsupported URL!", caption="Error!", style=wx.OK | wx.ICON_WARNING) error.ShowModal() error.Destroy() return self.num_songs = len(songs) self.progress_dialog = wx.ProgressDialog(title="Download", message="Downloading songs...", maximum=self.num_songs * 100, parent=self, style=PD_STYLE) self.downloader = DownloaderThread(self, songs, self.out_dir.GetPath()) self.downloader.start()
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 on_ok(self, event): if not os.path.exists(self.out_dir.GetPath()): os.makedirs(self.out_dir.GetPath()) self.num_songs = len(self.in_files) if self.num_songs <= 0: alert = wx.MessageDialog(self, "No songs selected!", "pyjam", wx.ICON_EXCLAMATION) alert.ShowModal() alert.Destroy() return self.progress_dialog = wx.ProgressDialog(title="Conversion", message="Converting songs...", maximum=self.num_songs * 2, parent=self, style=PD_STYLE) self.converter = FFmpegConvertThread(parent=self, dest=self.out_dir.GetPath(), rate=self.game_rate.GetValue(), vol=self.volume.GetValue(), songs=self.in_files) self.converter.start()
def convert_update(self, message): progress = "{songs} out of {total}".format(songs=message // 2, total=self.num_songs) if self.progress_dialog and self.converter.isAlive(): if message >= self.num_songs * 2: message = self.num_songs * 2 - 1 if not self.progress_dialog.Update(value=message, newmsg="Converted: {prog}".format(prog=progress))[0]: self.converter.abort() self.converter.join() self.progress_dialog.Destroy() alert_string = "Aborted! Only {progress} songs were converted".format(progress=progress) alert = wx.MessageDialog(parent=self, message=alert_string, caption="pyjam", style=wx.ICON_EXCLAMATION) alert.ToggleWindowStyle(wx.STAY_ON_TOP) alert.ShowModal() alert.Destroy() logger.info("Audio conversion canceled canceled.") logger.info(progress) # wx.CallAfter(self.progress_dialog.Destroy)
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 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 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 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 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 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 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 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_button_email_passwd(self,event):# Button save email and password email=self.text_ctrl_email.Value passwd=self.text_ctrl_email_passwd.Value if not self.V.validate_email(email)[0]: msg="Invalid Email" dlg = wx.MessageDialog(self, msg, 'Error',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return 0 self.DB.Set_SMS_Sender_Mail(email) self.DB.Set_SMS_Sender_Mail_Password(passwd) msg="Successfully Saved" dlg = wx.MessageDialog(self, msg, 'Success',wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.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 Login_Check(self,user,password): print "login check" passw=self.EN.Encrypt_Password(self.Secret_Key+password) query="SELECT PASSWORD FROM USER WHERE USER='%s' AND PASSWORD='%s'" %(user,passw) #self.DB.cur.execute(query,(user,self.Secret_Key+password,)) self.DB.cur.execute(query) #self.DB.con.commit() row=self.DB.cur.fetchone() if row: return True else: dlg = wx.MessageDialog(self.parent, 'Incorrect Password', '',wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return False
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 send_sms(self): print "sending",self.NO_MOBILE_LIST if self.NO_MOBILE_LIST: msg="The following Student(s) got no valid mobile numbers. Go to Student Profile to add/edit mobile numbers\n" no=0 for pupil in self.NO_MOBILE_LIST: no+=1 msg+=str(no)+". "+str(pupil)+"\n" #app = wx.PySimpleApp(0) dlg = wx.MessageDialog(None, msg,"No Mobile Number",wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
def Failed_Report(self): if len(self.Failed_List)==0: msg="All Students Passed" else: msg="The following Student(s) detained\n" no=0 for pupil in self.Failed_List: no+=1 msg+=str(no)+". "+str(pupil)+"\n" #app = wx.PySimpleApp(0) dlg = wx.MessageDialog(None, msg,str(self.class_)+self.div,wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
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 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 button_clicked(self, event): log.debug("[Settings] Button clicked: {0}".format(IDS[event.GetId()])) button_id = event.GetId() keys = IDS[button_id].split(MODULE_KEY) last_key = keys[-1] if last_key in ['list_add', 'list_remove']: self.on_list_operation(MODULE_KEY.join(keys[:-1]), action=last_key) elif last_key in ['ok_button', 'apply_button']: if self.save_settings(): log.debug('Got non-dynamic changes') dialog = wx.MessageDialog(self, message=translate_key(MODULE_KEY.join(['main', 'save', 'non_dynamic'])), caption="Caption", style=wx.OK_DEFAULT, pos=wx.DefaultPosition) dialog.ShowModal() if last_key == 'ok_button': self.on_exit(event) self.settings_saved = True elif last_key == 'cancel_button': self.on_close(event) event.Skip()
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 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 Send(self,message,level): message = message label = ('' if level>(len(self.labels)-1) else self.labels[level]) iconStyle = (0 if level>(len(self.iconStyles)-1) else self.iconStyles[level]) if self.logfile != None: self.logfile.write(label+": "+message) if level<=self.level: wx.MessageDialog(self.frame, message, label, wx.CENTRE | iconStyle).ShowModal() elif level<=self.silencelevel: self.frame.SetStatusText(label+": "+message)
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 onAbout(self,event): dlg = wx.MessageDialog(self,message="For more information visit:\n\nhttp://pyvision.sourceforge.net",style = wx.OK ) result = dlg.ShowModal()