zoukankan      html  css  js  c++  java
  • messagebox

     1 """messagebox消息框"""
     2 import tkinter as tk
     3 #导入messagebox
     4 import tkinter.messagebox as messagebox
     5 window = tk.Tk()
     6 window.title("My Window")
     7 window.geometry("400x400")
     8 var = tk.StringVar()
     9 var.set("Hello world")
    10 label = tk.Label(window,textvariable=var,font=("斜体",15),width=20,height=2,bg="black",fg="green")
    11 label.pack()
    12 def hit_me():
    13     global label #使用全局变量
    14     messagebox.showinfo(title="info",message="提示")
    15     messagebox.showwarning(title="warning",message="警告")
    16     messagebox.showerror(title="error",message="错误")
    17     """return yes or no"""
    18     question = messagebox.askquestion(title="question",message="问题")
    19     if question == "yes":
    20         var.set("you selection yes")
    21     else:
    22         var.set("you selection no")
    23     """return True or False"""
    24     askyesno = messagebox.askyesno(title="yes or no",message="选择")
    25     if askyesno == True:
    26         var.set("You selection True")
    27     else:
    28         var.set("You selection False")
    29     """return True or False"""
    30     askokcancel = messagebox.askokcancel(title="cancel",message="取消")
    31     if askokcancel == True:
    32         var.set("You selection cancel")
    33     else:
    34         var.set("You don't selection cancel")
    35     """return True False None"""
    36     result = messagebox.askyesnocancel(title="continue",message="Hello World")
    37     if result == True:
    38         var.set("You selection yes")
    39     elif result == False:
    40         var.set("You selection no")
    41     elif result == None:
    42         var.set("You selection cancel")
    43     """return True False"""
    44     try_cancel = messagebox.askretrycancel(title="try_cancel",message="Hello World")
    45     if try_cancel == True:
    46         var.set("You selection retry")
    47     else:
    48         var.set("You selection cancel")
    49 button = tk.Button(window,text="hit_me",command=hit_me,fg="red",bg="green")
    50 button.pack()
    51 window.mainloop()
    
    
  • 相关阅读:
    转:WinCE驱动开发问题精华集锦
    转:WINCE6.0+S3C6410下的DM9000A驱动
    转:WinCE6.0 不重启修改IP地址
    前端小功能:canvas验证码
    前端小功能:canvas签名版
    JavaScript中数组的应用方式
    ES6--Promise
    wepy 语法高亮
    Javascript和JQuery获取浏览器窗口各种尺寸
    图片预加载
  • 原文地址:https://www.cnblogs.com/py-peng/p/10327747.html
Copyright © 2011-2022 走看看