Python tkinter.messagebox.askokcancel() Examples
The following are 30
code examples of tkinter.messagebox.askokcancel().
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: base_file_browser.py From thonny with MIT License | 7 votes |
def move_to_trash(self): assert self.supports_trash() selection = self.get_selection_info(True) if not selection: return trash = "Recycle Bin" if running_on_windows() else "Trash" if not messagebox.askokcancel( "Moving to %s" % trash, "I'll try to move %s to %s,\n" % (selection["description"], trash) + "but my method is not always reliable —\n" + "in some cases the files will be deleted\n" + "without the possibility to restore.", icon="info", ): return self.perform_move_to_trash( selection["paths"], _("Moving %s to %s") % (selection["description"], trash) ) self.refresh_tree()
Example #2
Source File: gui.py From faceswap with GNU General Public License v3.0 | 7 votes |
def _confirm_close_on_running_task(self): """ Pop a confirmation box to close the GUI if a task is running Returns ------- bool: ``True`` if user confirms close, ``False`` if user cancels close """ if not self._config.tk_vars["runningtask"].get(): logger.debug("No tasks currently running") return True confirmtxt = "Processes are still running.\n\nAre you sure you want to exit?" if not messagebox.askokcancel("Close", confirmtxt, default="cancel", icon="warning"): logger.debug("Close Cancelled") return True logger.debug("Close confirmed") return False
Example #3
Source File: project.py From faceswap with GNU General Public License v3.0 | 7 votes |
def confirm_close(self): """ Pop a message box to get confirmation that an unsaved project should be closed Returns ------- bool: ``True`` if user confirms close, ``False`` if user cancels close """ if not self._modified: logger.debug("Project is not modified") return True confirmtxt = "You have unsaved changes.\n\nAre you sure you want to close the project?" if messagebox.askokcancel("Close", confirmtxt, default="cancel", icon="warning"): logger.debug("Close Cancelled") return True logger.debug("Close confirmed") return False
Example #4
Source File: AMS_Run.py From Attendace_management_system with MIT License | 5 votes |
def on_closing(): from tkinter import messagebox if messagebox.askokcancel("Quit", "Do you want to quit?"): window.destroy()
Example #5
Source File: spgl.py From Projects with GNU General Public License v3.0 | 5 votes |
def ask_ok_cancel(self, title, message): return messagebox.askokcancel(title, message)
Example #6
Source File: py_gui.py From pylinac with MIT License | 5 votes |
def gui(): def on_exit(): if messagebox.askokcancel("Quit", "Do you want to quit?"): root.quit() root = Tk() root.title('Pylinac GUI ' + __version__) root.protocol("WM_DELETE_WINDOW", on_exit) app = PylinacGUI(master=root) app.mainloop() root.destroy() del root
Example #7
Source File: files.py From thonny with MIT License | 5 votes |
def check_upload_download_response(command_name, command_response): if command_response and command_response.get("existing_files"): # command was not performed because overwriting existing files need confirmation existing = sorted(command_response["existing_files"][:25]) if len(command_response["existing_files"]) > 25: existing.append("...") user_response = messagebox.askokcancel( "Overwriting", "Some file(s) will be overwritten:\n\n" + " " + "\n ".join(existing), icon="info", ) if not user_response: return else: get_runner().send_command( InlineCommand( command_name, allow_overwrite=True, source_paths=command_response["source_paths"], target_dir=command_response["target_dir"], blocking=True, description=command_response["description"], ) )
Example #8
Source File: gui_elements.py From Airscript-ng with GNU General Public License v3.0 | 5 votes |
def pickOkOrCancel(windowTitle,windowText): return messagebox.askokcancel(windowTitle,windowText)
Example #9
Source File: PyShell.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #10
Source File: ScriptBinding.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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
Example #11
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
def ask_ok_cancel(self, title, message): return messagebox.askokcancel(title, message)
Example #12
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
def ask_ok_cancel(self, title, message): return messagebox.askokcancel(title, message)
Example #13
Source File: Window.py From yysScript with Apache License 2.0 | 5 votes |
def Closing(app): try: if messagebox.askokcancel("Quit", "Do you want to quit?"): StopAll(None) app.destroy() except Exception: sys.exit(-1)
Example #14
Source File: wicc_view_popup.py From WiCC with GNU General Public License v3.0 | 5 votes |
def okcancel(subject, text): return messagebox.askokcancel(subject, text)
Example #15
Source File: clai_emulator.py From clai with MIT License | 5 votes |
def on_closing(self, root): if messagebox.askokcancel("Quit", "Do you want to quit?"): self.presenter.stop_server() root.destroy()
Example #16
Source File: ScriptBinding.py From ironpython3 with Apache License 2.0 | 5 votes |
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
Example #17
Source File: 6.09.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def close_window(self): if messagebox.askokcancel("Quit", "Do you really want to quit?"): self.root.destroy()
Example #18
Source File: 3.12.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def exit_app(self): self.now_playing = False if messagebox.askokcancel("Quit", "Really quit?"): self.root.destroy()
Example #19
Source File: HiyaCFW_Helper.py From HiyaCFW-Helper with The Unlicense | 5 votes |
def change_mode(self): if (self.nand_mode): self.nand_frame.pack_forget() self.checks_frame.pack(padx=10, anchor=W) self.nand_mode = False else: if askokcancel('Warning', ('You are about to enter NAND mode. Do it only if you know ' 'what you are doing. Proceed?'), icon=WARNING): self.checks_frame.pack_forget() self.nand_frame.pack(padx=10, pady=(0, 10), fill=X) self.nand_mode = True ################################################################################################
Example #20
Source File: PyShell.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)
Example #21
Source File: ScriptBinding.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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
Example #22
Source File: pynpuzzle.py From pynpuzzle with MIT License | 5 votes |
def save_file_cmd(puzzle_frame, parent): """ Input's save to file button click handler puzzle_frame : The puzzle frame which it's puzzle will be saved to file parent : The parent window of the puzzle_frame This is used for showing the 'save as file' dialog so it can be showed on top of the window. """ # Check if puzzle frame has a valid input, and if not, ask the user if he's sure he wants to save the puzzle lst = is_input_puzzle_valid(puzzle_frame) if not lst: if not messagebox.askokcancel("Input not valid", "Input puzzle is not valid, are you sure to save it as a file?", parent=parent): return # Open the 'save as file' dialog file_name = filedialog.asksaveasfilename(title="Choose a file to save puzzle", parent=parent) # Check if user has selected a file if not file_name: return # Generate file's content len_sqrt = int(math.sqrt(len(lst))) file_lines = [] for i in range(0, len(lst), 3): line_nums = [] for j in range(0, len_sqrt): line_nums.append(str(lst[i + j])) file_lines.append(' '.join(line_nums)) try: with open(file_name, 'w') as file: file.write('\n'.join(file_lines)) except: messagebox.showerror("Error saving to file", "Some problem happened while saving puzzle to the file.", parent=parent) # Save to file button widgget
Example #23
Source File: PyShell.py From ironpython3 with Apache License 2.0 | 4 votes |
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)
Example #24
Source File: IOBinding.py From ironpython3 with Apache License 2.0 | 4 votes |
def print_window(self, event): confirm = tkMessageBox.askokcancel( title="Print", message="Print to Default Printer", default=tkMessageBox.OK, parent=self.text) if not confirm: self.text.focus_set() return "break" tempfilename = None saved = self.get_saved() if saved: filename = self.filename # shell undo is reset after every prompt, looks saved, probably isn't if not saved or filename is None: (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_') filename = tempfilename os.close(tfd) if not self.writefile(tempfilename): os.unlink(tempfilename) return "break" platform = os.name printPlatform = True if platform == 'posix': #posix platform command = idleConf.GetOption('main','General', 'print-command-posix') command = command + " 2>&1" elif platform == 'nt': #win32 platform command = idleConf.GetOption('main','General','print-command-win') else: #no printing for this platform printPlatform = False if printPlatform: #we can try to print for this platform command = command % shlex.quote(filename) pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() status = pipe.close() if status: output = "Printing failed (exit status 0x%x)\n" % \ status + output if output: output = "Printing command: %s\n" % repr(command) + output tkMessageBox.showerror("Print status", output, parent=self.text) else: #no printing for this platform message = "Printing is not enabled for this platform: %s" % platform tkMessageBox.showinfo("Print status", message, parent=self.text) if tempfilename: os.unlink(tempfilename) return "break"
Example #25
Source File: update_gui.py From Trade-Dangerous with Mozilla Public License 2.0 | 4 votes |
def checkValueAgainstStats(self, widget, stats): widget.configure(bg = 'white') minCr, avgCr, maxCr = stats if not avgCr: return True cr = int(widget.val.get()) if cr < int(minCr / 1.01) and cr < int(avgCr * 0.7): widget.bell() ok = mbox.askokcancel( "Very low price", "The price you entered is very low.\n" "\n" "Your input was: {}\n" "Previous low..: {}\n" "\n" "Is it correct?".format( cr, minCr, )) if not ok: self.selectWidget(widget, "") return False widget.configure(bg = '#ff8080') if cr >= (maxCr * 1.01) and int(cr * 0.7) > avgCr: widget.bell() ok = mbox.askokcancel( "Very high price", "The price you entered is very high.\n" "\n" "Your input was..: {}\n" "Previous highest: {}\n" "\n" "Is it correct?".format( cr, maxCr, )) if not ok: self.selectWidget(widget, "") return False widget.configure(bg = '#8080ff') return True
Example #26
Source File: IOBinding.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 4 votes |
def print_window(self, event): confirm = tkMessageBox.askokcancel( title="Print", message="Print to Default Printer", default=tkMessageBox.OK, parent=self.text) if not confirm: self.text.focus_set() return "break" tempfilename = None saved = self.get_saved() if saved: filename = self.filename # shell undo is reset after every prompt, looks saved, probably isn't if not saved or filename is None: (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_') filename = tempfilename os.close(tfd) if not self.writefile(tempfilename): os.unlink(tempfilename) return "break" platform = os.name printPlatform = True if platform == 'posix': #posix platform command = idleConf.GetOption('main','General', 'print-command-posix') command = command + " 2>&1" elif platform == 'nt': #win32 platform command = idleConf.GetOption('main','General','print-command-win') else: #no printing for this platform printPlatform = False if printPlatform: #we can try to print for this platform command = command % shlex.quote(filename) pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() status = pipe.close() if status: output = "Printing failed (exit status 0x%x)\n" % \ status + output if output: output = "Printing command: %s\n" % repr(command) + output tkMessageBox.showerror("Print status", output, parent=self.text) else: #no printing for this platform message = "Printing is not enabled for this platform: %s" % platform tkMessageBox.showinfo("Print status", message, parent=self.text) if tempfilename: os.unlink(tempfilename) return "break"
Example #27
Source File: IOBinding.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def print_window(self, event): confirm = tkMessageBox.askokcancel( title="Print", message="Print to Default Printer", default=tkMessageBox.OK, parent=self.text) if not confirm: self.text.focus_set() return "break" tempfilename = None saved = self.get_saved() if saved: filename = self.filename # shell undo is reset after every prompt, looks saved, probably isn't if not saved or filename is None: (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_') filename = tempfilename os.close(tfd) if not self.writefile(tempfilename): os.unlink(tempfilename) return "break" platform = os.name printPlatform = True if platform == 'posix': #posix platform command = idleConf.GetOption('main','General', 'print-command-posix') command = command + " 2>&1" elif platform == 'nt': #win32 platform command = idleConf.GetOption('main','General','print-command-win') else: #no printing for this platform printPlatform = False if printPlatform: #we can try to print for this platform command = command % shlex.quote(filename) pipe = os.popen(command, "r") # things can get ugly on NT if there is no printer available. output = pipe.read().strip() status = pipe.close() if status: output = "Printing failed (exit status 0x%x)\n" % \ status + output if output: output = "Printing command: %s\n" % repr(command) + output tkMessageBox.showerror("Print status", output, parent=self.text) else: #no printing for this platform message = "Printing is not enabled for this platform: %s" % platform tkMessageBox.showinfo("Print status", message, parent=self.text) if tempfilename: os.unlink(tempfilename) return "break"
Example #28
Source File: RAASNet.py From RAASNet with GNU General Public License v3.0 | 4 votes |
def decrypt_files(self): ask = confirm(text='What type of encryption are we dealing with?', buttons=['PyCrypto', 'PyAES', 'Ghost', "I don't know"]) if ask == "I don't know": messagebox.showinfo('Encryption type detection', 'Comming Soon!\n\nIf you really dont know, test it on one file first.') return if ask == 'Ghost': pass else: key = dec_key() key = key.encode('utf-8') if key == False: return p = dec_path() if p == False: return a = messagebox.askokcancel('WARNING', 'This tool will decrypt your files with the given key.\n\nHowever, if your key or method is not correct, your (encrypted) files will return corrupted.\n\n You might want to make a backup!') if a == True: pass else: return try: counter = 0 for path, subdirs, files in os.walk(p): for name in files: if name.endswith(".DEMON"): if ask == 'PyCrypto': decrypt_file(os.path.join(path, name), key) os.remove(os.path.join(path, name)) print("[Decrypted] %s" % name) counter+=1 elif ask == 'PyAES': print("[Decrypting] %s" % name) decrypt_file_pyaes(os.path.join(path, name), key) os.remove(os.path.join(path, name)) counter+=1 elif ask == 'Ghost': rename_file(os.path.join(path, name)) print("[RENAMED] %s" % name) counter+=1 elif name == 'README.txt': os.remove(os.path.join(path, name)) print('[DELETED] %s/%s' % (path, name)) else: print("[Skipped] %s" % name) print("\n[DONE] Decrypted %i files" % counter) except KeyboardInterrupt: print("\nInterrupted!\n") sys.exit(0) except Exception as e: print("\n[ ERROR ] %s" % e) sys.exit(1)
Example #29
Source File: decrypt.py From RAASNet with GNU General Public License v3.0 | 4 votes |
def decrypt_files(): ask = confirm(text='What type of encryption are we dealing with?', buttons=['PyCrypto', 'PyAES', 'Ghost', "I don't know"]) if ask == "I don't know": messagebox.showinfo('Encryption type detection', 'Comming Soon!\n\nIf you really dont know, test it on one file first.') return if ask == 'Ghost': pass else: key = dec_key() key = key.encode('utf-8') if key == False: return p = dec_path() if p == False: return a = messagebox.askokcancel('WARNING', 'This tool will decrypt your files with the given key.\n\nHowever, if your key or method is not correct, your (encrypted) files will return corrupted.\n\n You might want to make a backup!') if a == True: pass else: return try: counter = 0 for path, subdirs, files in os.walk(p): for name in files: if name.endswith(".DEMON"): if ask == 'PyCrypto': decrypt_file(os.path.join(path, name), key) print("[Decrypted] %s" % name) counter+=1 os.remove(os.path.join(path, name)) elif ask == 'PyAES': print("[Decrypting] %s" % name) decrypt_file_pyaes(os.path.join(path, name), key) counter+=1 os.remove(os.path.join(path, name)) elif ask == 'Ghost': rename_file(os.path.join(path, name)) print("[RENAMED] %s" % name) counter+=1 elif name == 'README.txt': os.remove(os.path.join(path, name)) print('[DELETED] %s/%s' % (path, name)) else: print("[Skipped] %s" % name) print("\n[DONE] Decrypted %i files" % counter) except KeyboardInterrupt: print("\nInterrupted!\n") sys.exit(0) except Exception as e: print("\n[ ERROR ] %s" % e) sys.exit(1)
Example #30
Source File: chapter4_02.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 4 votes |
def __init__(self): super().__init__() self.create_button(mb.askyesno, "Ask Yes/No", "Returns True or False") self.create_button(mb.askquestion, "Ask a question", "Returns 'yes' or 'no'") self.create_button(mb.askokcancel, "Ask Ok/Cancel", "Returns True or False") self.create_button(mb.askretrycancel, "Ask Retry/Cancel", "Returns True or False") self.create_button(mb.askyesnocancel, "Ask Yes/No/Cancel", "Returns True, False or None")