Tkinter之messageBox

https://blog.csdn.net/leak235/article/details/50529992   messagebox (python2中为tkMessageBox ):消息框,就是我们平时看到的弹窗。 需要定义一个触发功能,来触发这个弹窗,这里就用上前面学过的Button按钮,通过command调用功能,弹出各种类型的提示对话框。   示例: import Tkinter as tk  from tkMessageBox import *  # 此处是python2.7的用法,python3.x要改为:from tkinter.messagebox import *,注意大小写 window = tk.Tk() window.title('My Window') window.geometry('500x300')     def hit_me():     showinfo(title='Hi', message='正常文本')            # 提示信息对话窗     showwarning(title='Hi', message='有警告!')      # 提出警告对话窗     showerror(title='Hi', message='出错了!')          # 提出错误对话窗     askquestion(title='Hi', message='你好!')          # 询问选择对话窗return 'yes', 'no'     askyesno(title='Hi', message='你好!')              # return 'True', 'False'     askokcancel(title='Hi', message='你好!')         # return 'True', 'False'   l=tk.Button(window, text='hit me', bg='green', font=('Arial', 14), command=hit_me) l.pack()   window.mainloop()    
上一篇:基于MFC的网络编程(远程桌面监控)学习笔记(二)发消息


下一篇:C# 判断(Excel)文件是否已经打开