Tkinter.Messagebox模块

Messagebox模块

1.showinfo(title,message,options)
显示一般的提示信息。
from tkinter import *
from tkinter import messagebox
class Application(Frame):
    def __init__(self,master=None):
        super().__init__(master)
        self.master=master
        self.pack()
        self.createWidget()
    def createWidget(self):
        self.button=Button(self,text="退出",command=self.confirm).pack()

    def confirm(self):
        messagebox.showinfo("提示信息:","确定退出吗?")
if __name__ == '__main__':
    root=Tk()
    root.geometry('300x200')
    root.title('萤火虫')
    app=Application(master=root)
    root.mainloop()

在这里插入图片描述

2.showwarning(title,message,options)
显示警告信息
from tkinter import *
from tkinter import messagebox
class Application(Frame):
    def __init__(self,master=None):
        super().__init__(master)
        self.master=master
        self.pack()
        self.createWidget()
    def createWidget(self):
        self.button=Button(self,text="确认",command=self.confirm).pack()

    def confirm(self):
        messagebox.showwarning("提示信息:","病毒入侵")
if __name__ == '__main__':
    root=Tk()
    root.geometry('300x200')
    root.title('萤火虫')
    app=Application(master=root)
    root.mainloop()

在这里插入图片描述

3.showerror(title,message,options)
显示错误信息

在这里插入图片描述

4.askquestion(title,message,options)
显示询问消息。传回yes/no

在这里插入图片描述

5.askokcancel(title,message,options)
显示确定或取消消息。传回True/False

在这里插入图片描述

6.askyesno(title,message,options)
显示是与否消息。传回True/False

在这里插入图片描述

7.askyesnocancel(title,message,options)
显示是与否或取消消息。c传回Teue/False/None

在这里插入图片描述

8.askretrycancel(title,message,options)
显示重试或取消消息。传回True/False

在这里插入图片描述

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值