本文整理汇总了Python中tkinter.messagebox.askokcancel方法的典型用法代码示例。如果您正苦于以下问题:Python messagebox.askokcancel方法的具体用法?Python messagebox.askokcancel怎么用?Python messagebox.askokcancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块tkinter.messagebox的用法示例。
在下文中一共展示了messagebox.askokcancel方法的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: confirm_close
点赞 6
# 需要导入模块: 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
开发者ID:deepfakes,项目名称:faceswap,代码行数:18,
示例2: _confirm_close_on_running_task
点赞 6
# 需要导入模块: 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
开发者ID:deepfakes,项目名称:faceswap,代码行数:19,
示例3: move_to_trash
点赞 6
# 需要导入模块: 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()
开发者ID:thonny,项目名称:thonny,代码行数:24,
示例4: okcancel
点赞 5
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
def okcancel(subject, text):
return messagebox.askokcancel(subject, text)
开发者ID:pabloibiza,项目名称:WiCC,代码行数:4,
示例5: save_file_cmd
点赞 5
# 需要导入模块: 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
开发者ID:mahdavipanah,项目名称:pynpuzzle,代码行数:43,
示例6: ask_save_dialog
点赞 5
# 需要导入模块: 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
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,
示例7: close
点赞 5
# 需要导入模块: 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)
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,
示例8: change_mode
点赞 5
# 需要导入模块: 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
################################################################################################
开发者ID:mondul,项目名称:HiyaCFW-Helper,代码行数:17,
示例9: exit_app
点赞 5
# 需要导入模块: 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,
示例10: close_window
点赞 5
# 需要导入模块: 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,
示例11: on_closing
点赞 5
# 需要导入模块: 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()
开发者ID:IBM,项目名称:clai,代码行数:6,
示例12: on_closing
点赞 5
# 需要导入模块: 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()
开发者ID:Spidy20,项目名称:Attendace_management_system,代码行数:6,
示例13: Closing
点赞 5
# 需要导入模块: 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)
开发者ID:li-zheng-hao,项目名称:yysScript,代码行数:9,
示例14: ask_ok_cancel
点赞 5
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
def ask_ok_cancel(self, title, message):
return messagebox.askokcancel(title, message)
开发者ID:wynand1004,项目名称:SPGL,代码行数:4,
示例15: pickOkOrCancel
点赞 5
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
def pickOkOrCancel(windowTitle,windowText):
return messagebox.askokcancel(windowTitle,windowText)
开发者ID:Sh3llcod3,项目名称:Airscript-ng,代码行数:4,
示例16: check_upload_download_response
点赞 5
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
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"],
)
)
开发者ID:thonny,项目名称:thonny,代码行数:28,
示例17: gui
点赞 5
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
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
开发者ID:jrkerns,项目名称:pylinac,代码行数:15,
示例18: __init__
点赞 5
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
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")
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:14,
示例19: decrypt_files
点赞 4
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
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)
开发者ID:leonv024,项目名称:RAASNet,代码行数:58,
示例20: decrypt_files
点赞 4
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
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)
开发者ID:leonv024,项目名称:RAASNet,代码行数:58,
示例21: print_window
点赞 4
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
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"
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:51,
示例22: checkValueAgainstStats
点赞 4
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askokcancel [as 别名]
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
开发者ID:eyeonus,项目名称:Trade-Dangerous,代码行数:45,
注:本文中的tkinter.messagebox.askokcancel方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。