本文整理汇总了Python中tkinter.messagebox.askyesnocancel方法的典型用法代码示例。如果您正苦于以下问题:Python messagebox.askyesnocancel方法的具体用法?Python messagebox.askyesnocancel怎么用?Python messagebox.askyesnocancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.messagebox
的用法示例。
在下文中一共展示了messagebox.askyesnocancel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: maybesave
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def maybesave(self):
if self.get_saved():
return "yes"
message = "Do you want to save %s before closing?" % (
self.filename or "this untitled document")
confirm = tkMessageBox.askyesnocancel(
title="Save On Close",
message=message,
default=tkMessageBox.YES,
parent=self.text)
if confirm:
reply = "yes"
self.save(None)
if not self.get_saved():
reply = "cancel"
elif confirm is None:
reply = "cancel"
else:
reply = "no"
self.text.focus_set()
return reply
示例2: wclose
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def wclose(self, event=0):
if self.parent.title()[0] == "*":
save = messagebox.askyesnocancel(
"Save file",
"You have unsaved changes.\nDo you want to save before closing?",
)
if save:
self.save_file()
if self.parent.title()[0] == "*":
self.wclose()
else:
root.destroy()
elif not save:
root.destroy()
else:
root.destroy()
示例3: _msgBox
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def _msgBox():
# msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2017.')
# msg.showwarning('Python Message Warning Box', 'A Python GUI created using tkinter:\nWarning: There might be a bug in this code.')
# msg.showerror('Python Message Error Box', 'A Python GUI created using tkinter:\nError: Houston ~ we DO have a serious PROBLEM!')
answer = msg.askyesnocancel("Python Message Multi Choice Box", "Are you sure you really wish to do this?")
print(answer)
# Add another Menu to the Menu Bar and an item
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:10,代码来源:GUI_message_box_yes_no_cancel.py
示例4: action
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def action(self):
# 1 = True & 2 = False
if self.cb1.get() == 1:
self.payment_success()
elif self.cb2.get() == 1:
self.delete_1_record()
elif self.cb3.get() ==1:
self.retrive_decryption_key()
elif self.cb4.get() == 1:
ans = tmsg.askyesnocancel("Questions", "You are Going to Delete All Records, Are U Sure & Want to do this?")
if ans == True:
self.delete_all_record()
elif ans == False:
tmsg.showwarning("Warning", "Don't Tick this option, If you don't want to erase all DB_Records!")
示例5: _msgBox
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def _msgBox():
# msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2019.')
# msg.showwarning('Python Message Warning Box', 'A Python GUI created using tkinter:\nWarning: There might be a bug in this code.')
# msg.showerror('Python Message Error Box', 'A Python GUI created using tkinter:\nError: Houston ~ we DO have a serious PROBLEM!')
answer = msg.askyesnocancel("Python Message Multi Choice Box", "Are you sure you really wish to do this?")
print(answer)
# Add another Menu to the Menu Bar and an item
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Third-Edition,代码行数:10,代码来源:GUI_message_box_yes_no_cancel.py
示例6: check_save
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def check_save(self):
if not self.edited:
return True # No changes, all good
# Post a dialog asking if we want to save the current plist
answer = mb.askyesnocancel("Unsaved Changes", "Save changes to {}?".format(self.get_title()))
if answer == True:
return self.save_plist()
return answer
示例7: check_allow_closing
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def check_allow_closing(self, editor=None):
if not editor:
modified_editors = [e for e in self.winfo_children() if e.is_modified()]
else:
if not editor.is_modified():
return True
else:
modified_editors = [editor]
if len(modified_editors) == 0:
return True
message = "Do you want to save files before closing?"
if editor:
message = "Do you want to save file before closing?"
confirm = messagebox.askyesnocancel(
title="Save On Close", message=message, default=messagebox.YES
)
if confirm:
for editor_ in modified_editors:
if editor_.get_filename(True):
editor_.save_file()
else:
return False
return True
elif confirm is None:
return False
else:
return True
示例8: __init__
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [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")
示例9: capture_and_mark
# 需要导入模块: from tkinter import messagebox [as 别名]
# 或者: from tkinter.messagebox import askyesnocancel [as 别名]
def capture_and_mark(self):
sl = StudentsList(self.class_name)
students, roll_numbers = sl.load_pkl_file()
FaceDetectObj = FaceDetect(self.class_name)
Yes = True
No = False
Cancel = None
i = 0
while i <= 2:
captured_image=None
frame=None
students_present = []
while len(students_present) == 0:
captured_image, frame = capture()
students_present = FaceDetectObj.recognize(captured_image, roll_numbers)
if students_present == "No Training Data":
return
try:
name_student_present = students[roll_numbers.index(students_present[0])]
except:
messagebox.showerror("Error", "Recognized student not in database\nUnable to mark attendance")
return
response = messagebox.askyesnocancel("Confirm your identity", students_present[0]+'\n'+name_student_present)
if response is Yes:
wb = excel.attendance_workbook(self.class_name)
excel.mark_present(wb, students_present, self.class_name)
img_path=os.path.join(os.getcwd(), 'images', self.class_name, "s"+students_present[0][-2:],os.path.basename(captured_image))
cv2.imwrite(img_path,frame)
os.remove(captured_image)
messagebox.showinfo("Attendance Confirmation", "Your attendance is marked!")
break
elif response is Cancel:
break
elif response is No:
if i == 2:
img_path=os.path.join(os.getcwd(), 'images',self.class_name,"unrecognized students", os.path.basename(captured_image))
cv2.imwrite(img_path,frame)
messagebox.showinfo("Unrecognized Student", "You were not recognized as any student of this class.\nYour attendance will be marked later if you really are")
cv2.imwrite(img_path,frame)
os.remove(captured_image)
i += 1