本文整理匯總了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