askokcancel
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
# 创建主窗口
root = tkinter.Tk()
# 设置窗口大小
root.minsize(300,300)
# 声明函数
def okqqq():
# 弹出对话框
result = tkinter.messagebox.askokcancel(title = '标题',message = '内容:要吃饭嘛?')# 返回值为True或者False
print(result)
# 添加按钮
btn1 = tkinter.Button(root,text = 'ok',command = okqqq)
btn1.pack()
# 加入消息循环
root.mainloop()
![](https://i-blog.csdnimg.cn/blog_migrate/bcfbd91c121b7f1fdaf8751a269d266e.png)
askquestion
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
# 创建主窗口
root = tkinter.Tk()
# 设置窗口大小
root.minsize(300,300)
# 声明函数
def question():
# 弹出对话框
result = tkinter.messagebox.askquestion(title = '标题', message = '内容:你吃饭了嘛?')
# 返回值为:yes/no
print(result)
# 添加按钮
btn1 = tkinter.Button(root, text = 'question',command = question)
btn1.pack()
# 加入消息循环
root.mainloop()
![](https://i-blog.csdnimg.cn/blog_migrate/134ae7d9892bb526d07a8c0fe469db4a.png)
askretrycancel
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
# 创建主窗口
root = tkinter.Tk()
# 设置窗口大小
root.minsize(300,300)
# 声明函数
def retry():
# 弹出对话框
result = tkinter.messagebox.askretrycancel(title = '标题', message = '内容:女生拒绝了你!?')
# 返回值为:True或者False
print(result)
# 添加按钮
btn1 = tkinter.Button(root,text = 'retry', command = retry)
btn1.pack()
# 加入消息循环
root.mainloop()
![](https://i-blog.csdnimg.cn/blog_migrate/03a537a017508ffe3a3bf85561899f5d.png)
askyesno
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
# 创建主窗口
root = tkinter.Tk()
# 设置窗口大小
root.minsize(300,300)
# 声明函数
def yesno():
# 弹出对话框
result = tkinter.messagebox.askyesno(title = '标题',message = '内容:你喜欢我吗?')
# 返回值为:True或者False
print(result)
# 添加按钮
btn1 = tkinter.Button(root,text = 'yesno',command = yesno)
btn1.pack()
# 加入消息循环
root.mainloop()
![](https://i-blog.csdnimg.cn/blog_migrate/e0ea9bea8f99fc1ca8473a23aea8f1e1.png)
showerror
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
# 创建主窗口
root = tkinter.Tk()
# 设置窗口大小
root.minsize(300,300)
# 声明函数
def error():
# 弹出对话框
result = tkinter.messagebox.showerror(title = '出错了!',message='内容:你的年龄不符合要求。')
# 返回值为:ok
print(result)
# 添加按钮
btn1 = tkinter.Button(root,text = 'error',command = error)
btn1.pack()
# 加入消息循环
root.mainloop()
![](https://i-blog.csdnimg.cn/blog_migrate/8c88e092347156f862ddd2f82bac4742.png)
showwarning
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
# 创建主窗口
root = tkinter.Tk()
# 设置窗口大小
root.minsize(300,300)
# 声明函数
def warning():
# 弹出对话框
result = tkinter.messagebox.showwarning(title = '出错了!',message='内容:十八岁以下禁止进入。')
# 返回值为:ok
print(result)
# 添加按钮
btn1 = tkinter.Button(root,text = 'warning',command = warning)
btn1.pack()
# 加入消息循环
root.mainloop()
![](https://i-blog.csdnimg.cn/blog_migrate/af78be4bbab38ee574b041c4a45815df.png)
showinto
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
# 创建主窗口
root = tkinter.Tk()
# 设置窗口大小
root.minsize(300,300)
# 声明函数
def info():
# 弹出对话框
result = tkinter.messagebox.showinfo(title = '信息提示!',message='内容:您的女朋友收到一只不明来历的口红!')
# 返回值为:ok
print(result)
# 添加按钮
btn1 = tkinter.Button(root,text = 'info',command = info)
btn1.pack()
# 加入消息循环
root.mainloop()
![](https://i-blog.csdnimg.cn/blog_migrate/600b6bee4f63478a59272c54e0c91d21.png)