你好,下面是一个例子,你可以试试:
from tkinter import *
#import tkinter
import tkinter.messagebox as tm
import sys
#from Tkinter import *
#from tkMessageBox import *
def answer():
showerror("Answer", "Sorry, no answer available")
def callback():
if tm.askyesnocancel('Verify', 'Really quit?'):
print('Yes quit')
sys.exit(1)
else:
print('No')
Button(text='Quit', command=callback).pack(fill=X)
#Button(text='Answer', command=answer).pack(fill=X)
mainloop()