我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用tkMessageBox.askokcancel()。
def detect_bemoss(self): cwd = os.getcwd() ui_path = cwd.replace('bemoss_gui','bemoss_web_ui') cassandra_path = cwd.replace('bemoss_gui','cassandra') env_path = cwd.replace('bemoss_gui','bemoss_os/env/bin') bemoss_is_installed = os.path.isdir(ui_path) and os.path.isdir(cassandra_path) and os.path.isdir(env_path) if bemoss_is_installed is False: tmp = tkMessageBox.askokcancel(title='Please install BEMOSS at first', message='You computer does not have BEMOSS installed, do you want to install BEMOSS right now?', parent=root) if tmp is True: self.install_bemoss() return else: return False else: return True
def file_window(self): file_name = askopenfilename(parent=self.root, title='????', \ filetypes=[('FEN Records', '*.fen'), ('Text Files', '*.txt'), ('All Files', '*.*')], initialdir='Resourses/', \ initialfile='example.fen') # self.file = open(file_name, 'r') # self.play() # ''' try: self.file = open(file_name, 'r') self.play() except IOError: if askokcancel('?????', '???????'): self.file_window() else: self.root.destroy() # '''
def okBox(self, title, message): self.topLevel.update_idletasks() return MessageBox.askokcancel(title, message)
def quit(self): ans = askokcancel('Verify exit', "Really quit?") if ans: Frame.quit(self)
def MsgBox(title, text, style): box = [ msg.showinfo, msg.showwarning, msg.showerror, msg.askquestion, msg.askyesno, msg.askokcancel, msg.askretrycancel, ]; tk.Tk().withdraw(); #Hide Main Window. if style in range(7): return box[style](title, text)
def on_closing(): if msg.askokcancel("Warning", "Do you want to quit?"): background.destroy() rospy.signal_shutdown("")
def ask_ok_cancel(self, title, message): return messagebox.askokcancel(title, message)
def ask_quit(): global proc if tkMessageBox.askokcancel("Quit", "You want to leave me? *sniff*"): try: proc.terminate() except: pass sys.exit() #root.destroy() #-----------------------------------------
def message_ask_ok_cancel(title, mess): if VERSION == 3: result=tkinter.messagebox.askokcancel(title, mess) else: result=tkMessageBox.askokcancel(title, mess) return result ################################################################################ # Startup Application # ################################################################################
def menu_newTheme(self): """ callback for new_theme menu item """ sure = tkMessageBox.askokcancel(title='New Theme', message='sure?') if sure: self.newTheme()
def menu_loadTheme(self): """ callback for load_theme menu item """ newTheme = tkFileDialog.askopenfilename(initialdir=self.themeRootPath, filetypes=[('Theme', '*.json')], title='Open Theme') if newTheme and not newTheme.startswith(self.themeRootPath): tkMessageBox.showerror(message='Theme not in root folder: '+self.themeRootPath) print newTheme, self.themeRootPath return if not newTheme or (self.theme and not tkMessageBox.askokcancel(title='Loading theme', message='current theme will be lost. continue?')): return pathname, filename = os.path.split(newTheme) basename, themename = os.path.split(pathname) self.loadTheme(themename)
def close(self): "Extend EditorWindow.close()" if self.executing: response = tkMessageBox.askokcancel( "Kill?", "Your program is still running!\n Do you want to kill it?", default="ok", parent=self.text) if response is False: return "cancel" self.stop_readline() self.canceled = True self.closing = True return EditorWindow.close(self)
def ask_save_dialog(self): msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?" confirm = tkMessageBox.askokcancel(title="Save Before Run or Check", message=msg, default=tkMessageBox.OK, parent=self.editwin.text) return confirm
def request_next_annotation(self, *arg): value = self.user_tag_value.get() if value == "": self.root.bell() return if value not in self.annotation_state.parser_predictions.value_set: res = tkMessageBox.askokcancel( "New Tag", "You are about to introduce the new tag '{}'. Proceed?".format(value)) if res is False: return else: self.combobox.configure(values=sorted( list(self.annotation_state.parser_predictions.value_set) + [value])) self.annotation_state.process_annotation(self.current_request, value) comment_value = self.comment_box.get("1.0", END).strip() if len(comment_value) > 0: self.write_comment(self.current_request.token, comment_value, value) self.comment_box.delete("1.0", END) if self.autosave: self.save_state() self.get_next_request()
def message_ask_ok_cancel(title, mess): if VERSION == 3: result=tkinter.messagebox.askokcancel(title, mess) else: result=tkMessageBox.askokcancel(title, mess) return result ############################################################################ # routine takes an x and a y coords and does a coordinate transformation # # to a new coordinate system at angle from the initial coordinate system # # Returns new x,y tuple # ############################################################################
def _ResetToDefaultConfigCmd(self): q = tkMessageBox.askokcancel('Reset Configuration','Warning! This action will reset PiJuice HAT configuration to default settings.', parent=self.frame) if q: status = pijuice.config.SetDefaultConfiguration() if status['error'] != 'NO_ERROR': tkMessageBox.showerror('Reset to default configuration', status['error'], parent=self.frame)
def PiJuiceGuiOnclosing(): #if tkMessageBox.askokcancel("Quit", "Do you want to quit?"): if not os.path.exists(os.path.dirname(PiJuiceConfigDataPath)): print os.path.dirname(PiJuiceConfigDataPath) os.makedirs(os.path.dirname(PiJuiceConfigDataPath)) #try: with open(PiJuiceConfigDataPath , 'w+') as outputConfig: json.dump(pijuiceConfigData, outputConfig, indent=2) #except: #print root.destroy()
def start(self): print('--------------Start Gen Apk-------------------') # ????? # if os.path.exists(apks_dir): # shutil.rmtree(apks_dir) # ??apk?temp?? cmd_extract = r'java -jar %s\apktool\apktool_2.0.2.jar d -f -s %s\%s -o %s\temp' % (self.setupdir, self.setupdir, self.filename, self.setupdir) os.system(cmd_extract) # ??AndroidManifest.xml if os.path.exists('%s\AndroidManifest.xml' % self.setupdir): os.remove('%s\AndroidManifest.xml' % self.setupdir) manifest_path = r'%s\temp\AndroidManifest.xml' % self.setupdir shutil.copyfile(manifest_path, '%s\AndroidManifest.xml' % self.setupdir) # ????? for channel in self.channellist: print('[Gen Apk] channel : %s' % channel) self.modify_channel(channel) # ?????? if os.path.exists('%s\temp' % self.setupdir): shutil.rmtree('%s\temp' % self.setupdir) if os.path.exists('%s\AndroidManifest.xml' % self.setupdir): os.remove('%s\AndroidManifest.xml' % self.setupdir) flag = tkMessageBox.askokcancel("??", "????!") if flag: os.system("explorer.exe %s" % self.apkdir) print('--------------Done-------------------') # ?????
def on_closing(self): if (self.f_saved==False): if tkMessageBox.askokcancel("Quit", "Sampled data not saved. Do you wanto to quit?"): root.destroy() else: root.destroy()
def del_dat(self): cnt = tkMessageBox.askokcancel(title='Reconfirmation', message='Are you sure to delete the data?', parent=self.frame3) if cnt is True: cas_dir = self.bemoss_dir.replace('bemoss_os/', 'cassandra/') path = cas_dir + 'data' shutil.rmtree(path) else: return
def del_cas(self): cnt = tkMessageBox.askokcancel(title='Reconfirmation', message='Are you sure to delete the file?', parent=self.frame3) if cnt is True: path = self.bemoss_dir + '/cassandra_settings.txt' os.remove(path) else: return
def close(self): "Extend EditorWindow.close()" if self.executing: response = tkMessageBox.askokcancel( "Kill?", "The program is still running!\n Do you want to kill it?", default="ok", parent=self.text) if response is False: return "cancel" self.stop_readline() self.canceled = True self.closing = True # Wait for poll_subprocess() rescheduling to stop self.text.after(2 * self.pollinterval, self.close2)
def ask_save_dialog(self): msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?" confirm = tkMessageBox.askokcancel(title="Save Before Run or Check", message=msg, default=tkMessageBox.OK, master=self.editwin.text) return confirm
def execAction(self): if not self.action is None: action = getattr(self.controller, self.action) location = self.current_dir selection = self.getSelection() if len(selection) > 0: location = selection[0] if len(self.items_selected) > 0: if tkMessageBox.askokcancel(self.action.capitalize(), "Are you sure? This action can be permanent"): if action(self.items_selected, location): self.action = None else: tkMessageBox.showerror("Ops", "An error occurred :(") self.reloadMainList()
def install_examples(): # pragma: no cover """ Pops up windows to allow the user to choose a directory for installation of sfc_models examples. Uses tkinter, which is installed in base Python (modern versions). :return: """ if not mbox.askokcancel(title='sfc_models Example Installation', message=validate_str): return target = fdog.askdirectory(title='Choose directory to for sfc_models examples installation') if target == () or target == '': return install_example_scripts.install(target)
def play(self): self.erase() self.paint_board() try: self.put_chess() except IndexError: if askokcancel('????', '???????'): self.file_window() else: self.root.destroy() # ????FEN????