当前位置:   article > 正文

python中的tkinter包的使用--messagebox弹窗_tk.messagebox.showinfo

tk.messagebox.showinfo

效果依次为:

代码:

  1. import tkinter as tk
  2. import tkinter.messagebox
  3. window = tk.Tk()
  4. window.title('my window')
  5. window.geometry('200x200')
  6. def hit_me():
  7. #tk.messagebox.showinfo(title='Hi',message='hahahahha')
  8. #tk.messagebox.showerror(title='Hi',message='has error')
  9. #tk.messagebox.showwarning(title='Hi', message='has warning')
  10. #print(tk.messagebox.askokcancel(title='Hi',message='hahaha'))
  11. #print(tk.messagebox.askquestion(title='Hi', message='hahaha'))
  12. #print(tk.messagebox.askyesno(title='Hi', message='hahaha'))
  13. # print(tk.messagebox.askretrycancel(title='Hi', message='hahaha'))
  14. print(tk.messagebox.askyesnocancel(title='Hi', message='hahaha'))
  15. tk.Button(window,text='hit me',command=hit_me).pack()
  16. window.mainloop()

 

其中:

  1. tk.messagebox.showinfo(title='',message='')#提示信息对话窗
  2. tk.messagebox.showwarning()#提出警告对话窗
  3. tk.messagebox.showerror()#提出错误对话窗
  4. tk.messagebox.askquestion()#询问选择对话窗
  1. print(tk.messagebox.askquestion())#返回yes和no
  2. print(tk.messagebox.askokcancel())#返回truefalse
  3. print(tk.messagebox.askyesno())#返回truefalse
  4. print(tk.messagebox.askretrycancel())#返回truefalse

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/124825?site
推荐阅读
相关标签
  

闽ICP备14008679号