zoukankan      html  css  js  c++  java
  • Python GUI

    Python GUI - Tkinter tkMessageBox: tkMessageBox模块用于显示在您的应用程序的消息框。此模块提供了一个功能,您可以用它来显示适当的消息
     
     

    tkMessageBox模块用于显示在您的应用程序的消息框。此模块提供了一个功能,您可以用它来显示适当的消息.

    这些功能有些是showinfo,showwarning,showerror,askquestion,askokcancel,askyesno,askretryignore.

    方法:

    这里是一个简单的语法来创建这个widget:

    tkMessageBox.FunctionName(title, message [, options])
    

    参数:

    • FunctionName: 这是相应的消息框函数的名称.

    • title: 这是在一个消息框,标题栏显示的文本.

    • message: 这是要显示的文字作为消息.

    • options: 选项有替代的选择,你可以用它来定制一个标准的消息框。一些可以使用的选项是默认的。默认选项是用来指定默认的按钮,如中止,重试,或忽略在消息框中。父选项是用来指定要显示的消息框上的顶层窗口.

    If the standard message boxes are not appropriate, you can pick the closest alternative (askquestion, in most cases), and use options to change it to exactly suit your needs. You can use the following options (note that messageand title are usually given as arguments, not as options).

    default constant

    Which button to make default: ABORTRETRYIGNOREOKCANCEL,YES, or NO (the constants are defined in the tkMessageBox module).

    icon (constant)

    Which icon to display: ERRORINFOQUESTION, or WARNING

    message (string)

    The message to display (the second argument to the convenience functions). May contain newlines.

    parent (widget)

    Which window to place the message box on top of. When the message box is closed, the focus is returned to the parent window.

    title (string)

    Message box title (the first argument to the convenience functions).

    type (constant)

    Message box type; that is, which buttons to display:ABORTRETRYIGNOREOKOKCANCELRETRYCANCELYESNO, orYESNOCANCEL.

    • showinfo()

    • showwarning()

    • showerror ()

    • askquestion()

    • askokcancel()

    • askyesno ()

    • askretrycancel ()

    例子:

    自行尝试下面的例子:

    import Tkinter
    import tkMessageBox
    
    top = Tkinter.Tk()
    def hello():
       tkMessageBox.showinfo("Say Hello", "Hello World")
    
    B1 = Tkinter.Button(top, text = "Say Hello", command = hello)
    B1.pack()
    
    top.mainloop()
    

    这将产生以下结果:

     

    不显示window root窗口

    import Tkinter
    import tkMessageBox
     
    top = Tkinter.Tk()
    top.withdraw()
    tkMessageBox.askyesno("Say Hello", "Hello World")
    

      

      

  • 相关阅读:
    Sphinx安装配置应用
    错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
    常用Linux命令
    关于安卓开发的学习一:webview
    OpenFirewall
    C#启动或停止 计算机中“服务”
    关于C#操作防火墙,阻止程序联网
    用C#来控制高级安全Windows防火墙
    C#添加删除防火墙例外(程序、端口)
    C#Udp组播
  • 原文地址:https://www.cnblogs.com/hester/p/4898580.html
Copyright © 2011-2022 走看看