我们从Python开源项目中,提取了以下43个代码示例,用于说明如何使用wx.ICON_QUESTION。
def OnDelete(self, ev=None): """ Deleting selected items. """ tree = self.treeCtrlItems itemsL = tree.GetSelections() namesL = [] deleteL = [] for i in itemsL: # only items (ie. no groups) if tree.GetPyData(i) == 1: parent = tree.GetItemParent(i) parentName = tree.GetItemText(parent) name = tree.GetItemText(i).split()[0] #only name namesL.append('%s.%s' % (parentName, name)) deleteL.append(i) if namesL: namesS = ',\n '.join(namesL) ret = show_message_dialog(self, 'Really delete following name(s)?:\n %s' % namesS, '-- Confirm --', wx.YES|wx.NO|wx.ICON_QUESTION) if ret == wx.ID_YES: for name, i in zip(namesL,deleteL): if self.nsc_delete(name): tree.Delete(i)
def OnDeleteGroup(self, ev=None): """ Deleting selected groups. """ tree = self.treeCtrlItems itemsL = tree.GetSelections() namesL = [] deleteL = [] for i in itemsL: # only groups (ie. no items) if tree.GetPyData(i) == 0: name = tree.GetItemText(i) if name not in PROTECTED_GROUPS and tree.GetChildrenCount(i)==0: namesL.append(name) deleteL.append(i) if namesL: namesS = ',\n'.join(namesL) ret = show_message_dialog(self, 'Really delete following group(s)?:\n %s' % namesS, '-- Confirm --', wx.YES|wx.NO|wx.ICON_QUESTION) if ret == wx.ID_YES: for name, i in zip(namesL, deleteL): if self.nsc_delete_group(name): tree.Delete(i)
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 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 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 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 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 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 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 OnDisConnect(self): if logger != None: logger.info('desconecion') dlg = wx.MessageDialog(self.my_dialog_acceso_vcenter, 'Do you really want to close this application?', 'Confirm Exit', wx.OK | wx.CANCEL | wx.ICON_QUESTION) # wx.MessageDialog() result = dlg.ShowModal() #dlg.Destroy() if result == wx.ID_OK: dlg.Destroy() sys.exit(0) # ---------------------------------------------------------------------- # connect with Vcenter code and Dialog
def reboot_pigrow_click(self, e): dbox = wx.MessageDialog(self, "Are you sure you want to reboot the pigrow?", "reboot pigrow?", wx.OK | wx.CANCEL | wx.ICON_QUESTION) answer = dbox.ShowModal() dbox.Destroy() if (answer == wx.ID_OK): out, error = MainApp.localfiles_ctrl_pannel.run_on_pi("sudo reboot now") MainApp.pi_link_pnl.link_with_pi_btn_click("e") print out, error
def update_setting_click(self, e): #create updated settings file # #creating GPIO config block item_count = config_info_pnl.gpio_table.GetItemCount() # add dht22 sesnsor if present; if "dht22sensor" in self.gpio_dict: gpio_config_block = "\ngpio_dht22sensor=" + self.gpio_dict["dht22sensor"] else: gpio_config_block = "" # list all devices with gpio and wiring directions for count in range(0, item_count): device = config_info_pnl.gpio_table.GetItem(count, 0).GetText() gpio = config_info_pnl.gpio_table.GetItem(count, 1).GetText() wiring = config_info_pnl.gpio_table.GetItem(count, 2).GetText() gpio_config_block += "\ngpio_" + device + "=" + gpio gpio_config_block += "\ngpio_" + device + "_on=" + wiring # list all non-gpio settings other_settings = "" for key, value in self.config_dict.items(): other_settings += "\n" + key + "=" + value config_text = other_settings[1:] config_text += gpio_config_block # show user and ask user if they relly want to update dbox = wx.MessageDialog(self, config_text, "upload to pigrow?", wx.OK | wx.CANCEL | wx.ICON_QUESTION) answer = dbox.ShowModal() dbox.Destroy() #if user said ok then upload file to pi if (answer == wx.ID_OK): # # REPLACE THE FOLLOWING WITH A FUNCTION THAT ANYONE CAN CALL TO UPLOAD A FILE # sftp = ssh.open_sftp() folder = "/home/" + str(pi_link_pnl.target_user) + "/Pigrow/config/" f = sftp.open(folder + '/pigrow_config.txt', 'w') f.write(config_text) f.close()
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 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 OnClickClearButton(self,event): dlg = wx.MessageDialog(self, "Clear log?","Confirm clearing log", wx.OK|wx.CANCEL|wx.ICON_QUESTION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_OK: try: self.log.Clear() except: pass
def OnExit(self,e): dlg = wx.MessageDialog(self, "Exit Bonsu?","Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_OK: self.Destroy()
def OnNew(self,e): panelphase = self.GetChildren()[1].GetPage(0) if panelphase.pipeline_started == False: dlg = wx.MessageDialog(self, "Start a new session?"+os.linesep+"(This will erase the current session data)","Confirm New Session", wx.OK|wx.CANCEL|wx.ICON_QUESTION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_OK: NewInstance(self)
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 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 onInstall(): requiredVer = "Windows 10 Version 1703" # Translators: Dialog text shown when attempting to install the add-on on an unsupported version of Windows (minSupportedVersion is the minimum version required for this add-on). if sys.getwindowsversion().build < 15063 and gui.messageBox(_("You are using an older version of Windows. This add-on requires {minSupportedVersion} or later. Are you sure you wish to install this add-on anyway?").format(minSupportedVersion = requiredVer), # Translators: title of the dialog shown when attempting to install the add-on on an old version of Windows. _("Old Windows version"), wx.YES | wx.NO | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.NO: raise RuntimeError("Old Windows version detected")
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 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 _editWXGLADE(self): wxg_filename = self._getWXGLADEpath() open_wxglade = True if not self.GetCTRoot().CheckProjectPathPerm(): dialog = wx.MessageDialog(self.GetCTRoot().AppFrame, _("You don't have write permissions.\nOpen wxGlade anyway ?"), _("Open wxGlade"), wx.YES_NO | wx.ICON_QUESTION) open_wxglade = dialog.ShowModal() == wx.ID_YES dialog.Destroy() if open_wxglade: if not os.path.exists(wxg_filename): hmi_name = self.BaseParams.getName() open(wxg_filename, "w").write("""<?xml version="1.0"?> <application path="" name="" class="" option="0" language="python" top_window="%(name)s" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0"> <object class="%(class)s" name="%(name)s" base="EditFrame"> <style>wxDEFAULT_FRAME_STYLE</style> <title>frame_1</title> <object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer"> <orient>wxVERTICAL</orient> <object class="sizerslot" /> </object> </object> </application> """ % {"name": hmi_name, "class": "Class_%s" % hmi_name}) if wx.Platform == '__WXMSW__': wxg_filename = "\"%s\"" % wxg_filename self.launch_wxglade([wxg_filename])
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 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 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_pigrow_click(self, e): #reads button lable for check if update or install is required if self.update_pigrow_btn.GetLabel() == "update pigrow": do_upgrade = True #checks to determine best git merge stratergy if self.update_type == "clean": git_command = "git -C ~/Pigrow/ pull" elif self.update_type == "merge": print("WARNING WARNING _ THIS CODE IS VERY MUCH IN THE TESTING PHASE") print("if you're doing odd things it's very likely to mess up!") #this can cause odd confusions which requires use of 'git rebase' #reokace command line question with dialog box question = raw_input("merge using default, ours or theirs?") if question == "ours": git_command = "git -C ~/Pigrow/ pull --strategy=ours" #if we've changed a file it ignores the remote updated one elif question == "theirs": #often needs to commit or stash changes before working git_command = "git -C ~/Pigrow/ pull -s recursive -X theirs" #removes any changes made locally and replaces file with remote updated one elif question == "default": git_command = "git -C ~/Pigrow/ pull" else: print("not an option, calling the whole thing off...") do_upgrade = False #runs the git pull command using the selected stratergy if do_upgrade == True: dbox = wx.MessageDialog(self, "Are you sure you want to upgrade this pigrow?", "update pigrow?", wx.OK | wx.CANCEL | wx.ICON_QUESTION) answer = dbox.ShowModal() dbox.Destroy() #if user said ok then upload file to pi if (answer == wx.ID_OK): try: stdin, stdout, stderr = ssh.exec_command(git_command) responce = stdout.read().strip() error = stderr.read() print responce if len(error) > 0: print 'error:' + str(error) system_info_pnl.sys_pigrow_update.SetLabel("--UPDATED--") except Exception as e: print("ooops! " + str(e)) system_info_pnl.sys_pigrow_update.SetLabel("--UPDATE ERROR--") elif self.update_pigrow_btn.GetLabel() == "install pigrow": print("Downloading Pigrow code onto Pi") out, error = MainApp.localfiles_ctrl_pannel.run_on_pi("git clone https://github.com/Pragmatismo/Pigrow ~/Pigrow/") print out, error system_info_pnl.sys_pigrow_update.SetLabel("--NEW INSTALL--") print(" -- Installing software on pigrow ") out, error = MainApp.localfiles_ctrl_pannel.run_on_pi("~/Pigrow/scripts/config/install.py") print out, error