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()
python类ICON_QUESTION的实例源码
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 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 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