本文整理匯總了Python中tkinter.messagebox.askokcancel方法的典型用法代碼示例。如果您正苦於以下問題:Python messagebox.askokcancel方法的具體用法?Python messagebox.askokcancel怎麽用?Python messagebox.askokcancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tkinter.messagebox
的用法示例。
在下文中一共展示了messagebox.askokcancel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: confirm_close
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
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
示例2: _confirm_close_on_running_task
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
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
示例3: move_to_trash
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
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()
示例4: okcancel
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def okcancel(subject, text):
return messagebox.askokcancel(subject, text)
示例5: save_file_cmd
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
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
示例6: ask_save_dialog
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
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
示例7: close
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
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)
示例8: change_mode
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
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
################################################################################################
示例9: exit_app
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def exit_app(self):
self.now_playing = False
if messagebox.askokcancel("Quit", "Really quit?"):
self.root.destroy()
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代碼行數:6,代碼來源:3.12.py
示例10: close_window
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def close_window(self):
if messagebox.askokcancel("Quit", "Do you really want to quit?"):
self.root.destroy()
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代碼行數:5,代碼來源:6.09.py
示例11: on_closing
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def on_closing(self, root):
if messagebox.askokcancel("Quit", "Do you want to quit?"):
self.presenter.stop_server()
root.destroy()
示例12: on_closing
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def on_closing():
from tkinter import messagebox
if messagebox.askokcancel("Quit", "Do you want to quit?"):
window.destroy()
示例13: Closing
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def Closing(app):
try:
if messagebox.askokcancel("Quit", "Do you want to quit?"):
StopAll(None)
app.destroy()
except Exception:
sys.exit(-1)
示例14: ask_ok_cancel
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def ask_ok_cancel(self, title, message):
return messagebox.askokcancel(title, message)
示例15: pickOkOrCancel
# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def pickOkOrCancel(windowTitle,windowText):
return messagebox.askokcancel(windowTitle,windowText)