Python tkinter.messagebox.askyesno() Examples
The following are 30
code examples of tkinter.messagebox.askyesno().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter.messagebox
, or try the search function
.
Example #1
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 7 votes |
def find(self, text_to_find): length = tk.IntVar() idx = self.search(text_to_find, self.find_search_starting_index, stopindex=tk.END, count=length) if idx: self.tag_remove('find_match', 1.0, tk.END) end = f'{idx}+{length.get()}c' self.tag_add('find_match', idx, end) self.see(idx) self.find_search_starting_index = end self.find_match_index = idx else: if self.find_match_index != 1.0: if msg.askyesno("No more results", "No further matches. Repeat from the beginning?"): self.find_search_starting_index = 1.0 self.find_match_index = None return self.find(text_to_find) else: msg.showinfo("No Matches", "No matching text found")
Example #2
Source File: wrapper.py From MindMap with MIT License | 7 votes |
def sheetRightClick(sheet, event=[]): deleteSheet = messagebox.askyesno("Deletion Confirmation", "Would you like to delete the page "+sheet['name']+'?') if deleteSheet: filename = sheet['filename'] print("deleting ", filename) cmd = 'rm '+filename subprocess.call(cmd+" >/dev/null 2>&1 &", shell=True) # now need to redraw window init_pages()
Example #3
Source File: Controlador.py From proyectoDownloader with MIT License | 6 votes |
def cargarFB(self): try: rpta = msg.askyesno("Pregunta", "No se puede obtener información "+ "de un video de facebook, desea continuar con la descarga?") if rpta: path = filedialog.asksaveasfilename() os.popen("facebook-dl.py {} hd {}".format(self.vista.url.get(),path)) msg.showinfo("Mensaje", "Archivo descargado correctamente.") except: msg.showerror("Error", "El video no es público, o la url es inválida.") self.vista.button.config(state=NORMAL) self.vista.bvideo.config(state=NORMAL) self.vista.baudio.config(state=NORMAL) self.vista.bborrar.config(state=NORMAL) self.vista.config(cursor="")
Example #4
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def find(self, text_to_find): length = tk.IntVar() idx = self.search(text_to_find, self.find_search_starting_index, stopindex=tk.END, count=length) if idx: self.tag_remove('find_match', 1.0, tk.END) end = f'{idx}+{length.get()}c' self.tag_add('find_match', idx, end) self.see(idx) self.find_search_starting_index = end self.find_match_index = idx else: if self.find_match_index != 1.0: if msg.askyesno("No more results", "No further matches. Repeat from the beginning?"): self.find_search_starting_index = 1.0 self.find_match_index = None return self.find(text_to_find) else: msg.showinfo("No Matches", "No matching text found")
Example #5
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def find(self, text_to_find): length = tk.IntVar() idx = self.search(text_to_find, self.find_search_starting_index, stopindex=tk.END, count=length) if idx: self.tag_remove('find_match', 1.0, tk.END) end = f'{idx}+{length.get()}c' self.tag_add('find_match', idx, end) self.see(idx) self.find_search_starting_index = end self.find_match_index = idx else: if self.find_match_index != 1.0: if msg.askyesno("No more results", "No further matches. Repeat from the beginning?"): self.find_search_starting_index = 1.0 self.find_match_index = None return self.find(text_to_find) else: msg.showinfo("No Matches", "No matching text found")
Example #6
Source File: gprpyGUI.py From GPRPy with MIT License | 6 votes |
def exportVTK(self,proj): outfile = fd.asksaveasfilename() if outfile is not '': #thickness = sd.askfloat("Input","Profile thickness [m]") thickness = 0 if self.asp is None: aspect = 1.0 else: aspect = self.asp if proj.threeD is None: gpyes = mesbox.askyesno("Question","Do you have topography data for this profile?") if gpyes: filename = fd.askopenfilename() self.getDelimiter() proj.exportVTK(outfile,gpsinfo=filename,thickness=thickness,delimiter=self.delimiter,aspect=aspect) else: proj.exportVTK(outfile,gpsinfo=proj.threeD,thickness=thickness,delimiter=self.delimiter,aspect=aspect) print('... done with exporting to VTK.')
Example #7
Source File: EditorWindow.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def toggle_tabs_event(self, event): if self.askyesno( "Toggle tabs", "Turn tabs " + ("on", "off")[self.usetabs] + "?\nIndent width " + ("will be", "remains at")[self.usetabs] + " 8." + "\n Note: a tab is always 8 columns", parent=self.text): self.usetabs = not self.usetabs # Try to prevent inconsistent indentation. # User must change indent width manually after using tabs. self.indentwidth = 8 return "break" # XXX this isn't bound to anything -- see tabwidth comments ## def change_tabwidth_event(self, event): ## new = self._asktabwidth() ## if new != self.tabwidth: ## self.tabwidth = new ## self.set_indentation_params(0, guess=0) ## return "break"
Example #8
Source File: EditorWindow.py From ironpython3 with Apache License 2.0 | 6 votes |
def toggle_tabs_event(self, event): if self.askyesno( "Toggle tabs", "Turn tabs " + ("on", "off")[self.usetabs] + "?\nIndent width " + ("will be", "remains at")[self.usetabs] + " 8." + "\n Note: a tab is always 8 columns", parent=self.text): self.usetabs = not self.usetabs # Try to prevent inconsistent indentation. # User must change indent width manually after using tabs. self.indentwidth = 8 return "break" # XXX this isn't bound to anything -- see tabwidth comments ## def change_tabwidth_event(self, event): ## new = self._asktabwidth() ## if new != self.tabwidth: ## self.tabwidth = new ## self.set_indentation_params(0, guess=0) ## return "break"
Example #9
Source File: plistwindow.py From ProperTree with BSD 3-Clause "New" or "Revised" License | 6 votes |
def reload_from_disk(self, event = None): # If we have opened a file, let's reload it from disk # We'll dump the current undo stack, and load it fresh if not self.current_plist: # Nothing to do - ding and bail self.bell() return # At this point - we should check if we have edited the file, and if so # prompt the user if self.edited: self.bell() if not mb.askyesno("Unsaved Changes","Any unsaved changes will be lost when reloading from disk. Continue?",parent=self): return # If we got here - we're okay with dumping changes (if any) try: with open(self.current_plist,"rb") as f: plist_data = plist.load(f,dict_type=dict if self.controller.settings.get("sort_dict",False) else OrderedDict) except Exception as e: # Had an issue, throw up a display box self.bell() mb.showerror("An Error Occurred While Opening {}".format(os.path.basename(self.current_plist)), str(e),parent=self) return # We should have the plist data now self.open_plist(self.current_plist,plist_data, self.plist_type_string.get())
Example #10
Source File: sqlite_bro.py From sqlite_bro with MIT License | 6 votes |
def new_db(self, filename=''): """create a new database""" if filename == '': filename = filedialog.asksaveasfilename( initialdir=self.initialdir, defaultextension='.db', title="Define a new database name and location", filetypes=[("default", "*.db"), ("other", "*.db*"), ("all", "*.*")]) if filename != '': self.database_file = filename if os.path.isfile(filename): self.set_initialdir(filename) if messagebox.askyesno( message='Confirm Destruction of previous Datas ?', icon='question', title='Destroying'): os.remove(filename) self.conn = Baresql(self.database_file) self.actualize_db()
Example #11
Source File: OpenTool.py From Open-Manager with MIT License | 6 votes |
def deleteitem(self): index = self.listbox.curselection() try: item = self.listbox.get(index) except TclError: messagebox.showinfo('提示', '请选择需删除的项目!') # messagebox.showwarning('警告','请选择需删除的项目!') return if messagebox.askyesno('删除', '删除 %s ?' % item): self.listbox.delete(index) del self.urllist[item] messagebox.showinfo('提示', '删除成功') else: # messagebox.showinfo('No', 'Quit has been cancelled') return # for item in index: # print(self.listbox.get(item)) # self.listbox.delete(item) # print(index) # urlname = self.listbox.get(self.listbox.curselection()) # print(urlname)
Example #12
Source File: EditorWindow.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def toggle_tabs_event(self, event): if self.askyesno( "Toggle tabs", "Turn tabs " + ("on", "off")[self.usetabs] + "?\nIndent width " + ("will be", "remains at")[self.usetabs] + " 8." + "\n Note: a tab is always 8 columns", parent=self.text): self.usetabs = not self.usetabs # Try to prevent inconsistent indentation. # User must change indent width manually after using tabs. self.indentwidth = 8 return "break" # XXX this isn't bound to anything -- see tabwidth comments ## def change_tabwidth_event(self, event): ## new = self._asktabwidth() ## if new != self.tabwidth: ## self.tabwidth = new ## self.set_indentation_params(0, guess=0) ## return "break"
Example #13
Source File: tktextext.py From thonny with MIT License | 6 votes |
def check_convert_tabs_to_spaces(self, chars): if not self.replace_tabs: return chars tab_count = chars.count("\t") if tab_count == 0: return chars else: if messagebox.askyesno( "Convert tabs to spaces?", "Thonny (according to Python recommendation) uses spaces for indentation, " + "but the text you are about to insert/open contains %d tab characters. " % tab_count + "To avoid confusion, it's better to convert them into spaces (unless you know they should be kept as tabs).\n\n" + "Do you want me to replace each tab with %d spaces?\n\n" % self.indent_width, ): return chars.expandtabs(self.indent_width) else: return chars
Example #14
Source File: config.py From thonny with MIT License | 6 votes |
def try_load_configuration(filename): if filename in _manager_cache: return _manager_cache[filename] try: # use cache so Workbench doesn't create duplicate manager # when FirstRunWindow already created one mgr = ConfigurationManager(filename) _manager_cache[filename] = mgr return mgr except configparser.Error: from tkinter import messagebox if os.path.exists(filename) and messagebox.askyesno( "Problem", "Thonny's configuration file can't be read. It may be corrupt.\n\n" + "Do you want to discard the file and open Thonny with default settings?", ): os.replace(filename, filename + "_corrupt") # For some reasons Thonny styles are not loaded properly once messagebox has been shown before main window (At least Windows Py 3.5) raise SystemExit("Configuration file has been discarded. Please restart Thonny!") else: raise
Example #15
Source File: pip_gui.py From thonny with MIT License | 6 votes |
def _confirm_install(self, package_data): name = package_data["info"]["name"] if name.lower().startswith("thonny"): return messagebox.askyesno( _("Confirmation"), _( "Looks like you are installing a Thonny-related package.\n" + "If you meant to install a Thonny plugin, then you should\n" + "choose 'Tools → Manage plugins...' instead\n" + "\n" + "Are you sure you want to install %s for the back-end?" ) % name, ) else: return True
Example #16
Source File: run this one.py From my_research with Apache License 2.0 | 5 votes |
def button_save_learning_result_clicked(self): global episode if os.path.exists('q_table_trained_{}_episode.pickle'.format(episode)) \ and os.path.exists('q_index_trained_{}_episode.pickle'.format(episode)): answer = messagebox.askyesno(message="Hunter's experience has already saved,\nSave again?") if answer == True: hunter.q_table.to_pickle('q_table_trained_{}_episode.pickle'.format(episode)) hunter.q_index.to_pickle('q_index_trained_{}_episode.pickle'.format(episode)) messagebox.showinfo(message="Hunter's experience has been saved") else: hunter.q_table.to_pickle('q_table_trained_{}_episode.pickle'.format(episode)) hunter.q_index.to_pickle('q_index_trained_{}_episode.pickle'.format(episode)) messagebox.showinfo(message="Hunter's experience has been saved")
Example #17
Source File: spgl.py From Projects with GNU General Public License v3.0 | 5 votes |
def ask_yes_no(self, title, message): return messagebox.askyesno(title, message)
Example #18
Source File: record.py From TensorKart with MIT License | 5 votes |
def start_recording(self): should_record = True # check that a dir has been specified if not self.outputDirStrVar.get(): tkMessageBox.showerror(title='Error', message='Specify the Output Directory', parent=self.root) should_record = False else: # a directory was specified self.outputDir = self.outputDirStrVar.get() # check if path exists - i.e. may be saving over data if os.path.exists(self.outputDir): # overwrite the data, yes/no? if tkMessageBox.askyesno(title='Warning!', message='Output Directory Exists - Overwrite Data?', parent=self.root): # delete & re-make the dir: shutil.rmtree(self.outputDir) os.mkdir(self.outputDir) # answer was 'no', so do not overwrite the data else: should_record = False self.txt_outputDir.focus_set() # directory doesn't exist, so make one else: os.mkdir(self.outputDir) self.recording = should_record
Example #19
Source File: base_file_browser.py From thonny with MIT License | 5 votes |
def on_ok(self, event=None): tree = self.browser.tree name = self.name_var.get() for node_id in tree.get_children(""): if name == tree.set(node_id, "name"): break else: node_id = None if node_id is not None: node_kind = tree.set(node_id, "kind") if node_kind != "file": messagebox.showerror(_("Error"), _("You need to select a file!")) return elif self.kind == "save": if not messagebox.askyesno( _("Overwrite?"), _("Do you want to overwrite '%s' ?") % name ): return parent_path = tree.set("", "path") if parent_path == "" or parent_path.endswith("/"): self.result = parent_path + name else: self.result = parent_path + "/" + name self.destroy()
Example #20
Source File: base_file_browser.py From thonny with MIT License | 5 votes |
def delete(self): selection = self.get_selection_info(True) if not selection: return confirmation = "Are you sure want to delete %s?" % selection["description"] confirmation += "\n\nNB! Recycle bin won't be used (no way to undelete)!" if "dir" in selection["kinds"]: confirmation += "\n" + "Directories will be deleted with content." if not messagebox.askyesno("Are you sure?", confirmation): return self.perform_delete(selection["paths"], _("Deleting %s") % selection["description"]) self.refresh_tree()
Example #21
Source File: ui_utils.py From thonny with MIT License | 5 votes |
def _close(self, event=None): if self._proc.poll() is None: if messagebox.askyesno( _("Cancel the process?"), _("The process is still running.\nAre you sure you want to cancel?"), parent=None if running_on_mac_os() else self, ): # try gently first try: if running_on_windows(): os.kill(self._proc.pid, signal.CTRL_BREAK_EVENT) # @UndefinedVariable else: os.kill(self._proc.pid, signal.SIGINT) self._proc.wait(2) except subprocess.TimeoutExpired: if self._proc.poll() is None: # now let's be more concrete self._proc.kill() self.cancelled = True # Wait for threads to finish self._stdout_thread.join(2) if self._stderr_thread is not None: self._stderr_thread.join(2) # fetch output about cancelling while len(self._event_queue) > 0: stream_name, data = self._event_queue.popleft() self.text.direct_insert("end", data, tags=(stream_name,)) self.text.direct_insert("end", "\n\nPROCESS CANCELLED") self.text.see("end") else: return else: self._closed = True self.destroy()
Example #22
Source File: ui_utils.py From thonny with MIT License | 5 votes |
def try_remove_linenumbers(text, master): try: if has_line_numbers(text) and messagebox.askyesno( title="Remove linenumbers", message="Do you want to remove linenumbers from pasted text?", default=messagebox.YES, ): return remove_line_numbers(text) else: return text except Exception: traceback.print_exc() return text
Example #23
Source File: gui_elements.py From Airscript-ng with GNU General Public License v3.0 | 5 votes |
def pickYesOrNo(windowTitle,windowText): return messagebox.askyesno(windowTitle,windowText) #Define function to ask retry/cancel question
Example #24
Source File: configDialog.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def DeleteCustomTheme(self): themeName = self.customTheme.get() delmsg = 'Are you sure you wish to delete the theme %r ?' if not tkMessageBox.askyesno( 'Delete Theme', delmsg % themeName, parent=self): return self.DeactivateCurrentConfig() #remove theme from config idleConf.userCfg['highlight'].remove_section(themeName) if themeName in self.changedItems['highlight']: del(self.changedItems['highlight'][themeName]) #write changes idleConf.userCfg['highlight'].Save() #reload user theme list itemList = idleConf.GetSectionList('user', 'highlight') itemList.sort() if not itemList: self.radioThemeCustom.config(state=DISABLED) self.optMenuThemeCustom.SetMenu(itemList, '- no custom themes -') else: self.optMenuThemeCustom.SetMenu(itemList, itemList[0]) #revert to default theme self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme', 'default')) self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme', 'name')) #user can't back out of these changes, they must be applied now self.SaveAllChangedConfigs() self.ActivateConfigChanges() self.SetThemeType()
Example #25
Source File: configDialog.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def DeleteCustomKeys(self): keySetName=self.customKeys.get() delmsg = 'Are you sure you wish to delete the key set %r ?' if not tkMessageBox.askyesno( 'Delete Key Set', delmsg % keySetName, parent=self): return self.DeactivateCurrentConfig() #remove key set from config idleConf.userCfg['keys'].remove_section(keySetName) if keySetName in self.changedItems['keys']: del(self.changedItems['keys'][keySetName]) #write changes idleConf.userCfg['keys'].Save() #reload user key set list itemList = idleConf.GetSectionList('user', 'keys') itemList.sort() if not itemList: self.radioKeysCustom.config(state=DISABLED) self.optMenuKeysCustom.SetMenu(itemList, '- no custom keys -') else: self.optMenuKeysCustom.SetMenu(itemList, itemList[0]) #revert to default key set self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys', 'default')) self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys', 'name')) #user can't back out of these changes, they must be applied now self.SaveAllChangedConfigs() self.ActivateConfigChanges() self.SetKeysType()
Example #26
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
def ask_yes_no(self, title, message): return messagebox.askyesno(title, message)
Example #27
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
def ask_yes_no(self, title, message): return messagebox.askyesno(title, message)
Example #28
Source File: capture.py From Attendance-Management-using-Face-Recognition with GNU General Public License v3.0 | 5 votes |
def detect_faces(cascade_xml, bgr_img, scaleFactor=1.1): img = bgr_img.copy() gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) clf = cv2.CascadeClassifier(cascade_xml) faces = clf.detectMultiScale(gray, scaleFactor, 5) if len(faces) == 0 or len(faces) > 1: return False for (x, y, w, h) in faces: cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2) cv2.imshow("Training Image", img) cv2.waitKey(0) response = messagebox.askyesno("Verify", "Has you face been properly detected and marked ?") cv2.destroyAllWindows() return response
Example #29
Source File: OpenTool.py From Open-Manager with MIT License | 5 votes |
def ok(self, event=None): urlname = self.name.get().strip() url = self.url.get().strip() if urlname == '' or url == '': messagebox.showwarning('警告', '输入不能为空!') return # if self.parent.urllist.has_key(self.parent.name): # has_key() 方法 if urlname in self.parent.urllist: if messagebox.askyesno('提示', '名称 ‘%s’ 已存在,将会覆盖,是否继续?' % urlname): pass else: return # 顯式地更改父窗口參數 # self.parent.name = urlname # self.parent.url = url self.parent.urllist[urlname] = url # 重新加载列表 self.parent.listbox.delete(0, END) for item in self.parent.urllist: self.parent.listbox.insert(END, item) self.destroy() # 銷燬窗口
Example #30
Source File: ch1-6.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def say_goodbye(self): if msgbox.askyesno("Close Window?", "Would you like to close this window?"): message = "Window will close in 2 seconds - goodybye " + self.name_entry.get() self.label_text.set(message) self.after(2000, self.destroy) else: msgbox.showinfo("Not Closing", "Great! This window will stay open.")