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

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

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

方法:

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

  1. 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 ()

例子:

自行尝试下面的例子:

  1. import Tkinter
  2. import tkMessageBox
  3.  
  4. top = Tkinter.Tk()
  5. def hello():
  6. tkMessageBox.showinfo("Say Hello", "Hello World")
  7.  
  8. B1 = Tkinter.Button(top, text = "Say Hello", command = hello)
  9. B1.pack()
  10.  
  11. top.mainloop()

这将产生以下结果:

 

不显示window root窗口

  1. import Tkinter
  2. import tkMessageBox
  3.  
  4. top = Tkinter.Tk()
  5. top.withdraw()
  6. tkMessageBox.askyesno("Say Hello", "Hello World")

  

  

Python GUI - Tkinter tkMessageBox的更多相关文章

  1. Python GUI - tkinter

    目录: Tkinter 组件 标准属性 几何管理 代码实例: 1. Label & Button 2. Entry & Text 3.Listbox列表 4.Radiobutton单选 ...

  2. python gui tkinter快速入门教程 | python tkinter tutorial

    本文首发于个人博客https://kezunlin.me/post/d5c57f56/,欢迎阅读最新内容! python tkinter tutorial Guide main ui messageb ...

  3. Python GUI——tkinter菜鸟编程(中)

    8. Radiobutton 选项按钮:可以用鼠标单击方式选取,一次只能有一个选项被选取. Radiobutton(父对象,options,-) 常用options参数: anchor,bg,bitm ...

  4. python gui tkinter用法杂记

    1.treeview遍历 iids = tree.selection() t = tree.get_children() for i in t: print(tree.item(i,'values') ...

  5. Python GUI tkinter 学习笔记(一)

    第一个python程序 #!/usr/bin/python # -*- coding: UTF-8 -*- from Tkinter import * # 创建一个根窗口,其余的控件都在这个窗口之上 ...

  6. Python GUI tkinter 学习笔记(三)

    草稿 # -*- coding: utf-8 -*- from Tkinter import * root = Tk() Label(root, text = "First").g ...

  7. Python GUI tkinter 学习笔记(二)

    第二个程序 # -*- coding: utf-8 -*- from Tkinter import * class App: def __init__(self, master): # frame 创 ...

  8. Python GUI with Tkinter (from youtube) 在youtube上能找到很多编程视频...

    Python GUI with Tkinter - 1 - Introduction以上链接是一个python tkinter视频系列的第一讲的链接.虽然英语不好,但是,程序还是看得懂的(照着做就可以 ...

  9. Python GUI之tkinter窗口视窗教程大集合(看这篇就够了)

    一.前言 由于本篇文章较长,所以下面给出内容目录方便跳转阅读,当然也可以用博客页面最右侧的文章目录导航栏进行跳转查阅. 一.前言 二.Tkinter 是什么 三.Tkinter 控件详细介绍 1. T ...

随机推荐

  1. CDN架构以及原理分析

    详见: http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp61  在不同地域的用户访问网站的响应速度存在差异,为了提高用户访问的响应 ...

  2. 使用XmlWriter创建XML文件

    using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Xml ...

  3. Angular+ionic2 web端 启动程序出现短暂 白屏或黑屏 的处理小妙招

    在ionic2项目启动是会出现短暂的白屏或者黑屏,虽然很短,但是用户体验不太好.上网查了相关的资料,都是针对打包APP的解决办法,针对浏览器端使用的项目没有效果,所以自己写了样式,巧妙的避开这个问题, ...

  4. Java课程设计——博客作业教学数据分析系统(201521123091 李嘉廉)

    #课程设计--博客作业教学数据分析系统(201521123084 李嘉廉) 1.团队课程设计博客链接 博客作业教学数据分析系统 2.个人负责模块或任务说明 數據分析 Kmeans聚類算法實現 多元綫性 ...

  5. 蓝桥杯PREV-11:横向打印二叉树

    嗯,没错我还报了蓝桥杯. 这是题目 问题描述 二叉树可以用于排序.其原理很简单:对于一个排序二叉树添加新节点时,先与根节点比较,若小则交给左子树继续处理,否则交给右子树. 当遇到空子树时,则把该节点放 ...

  6. 【Alpha】Daily Scrum Meeting——Day2

    站立式会议照片 1.本次会议为第二次 Meeting会议: 2.本次会议在中午12:30,在陆大楼召开,本次会议为30分钟讨论昨天的任务完成情况以及接下来的任务安排. 每个人的工作分配 成 员 昨天已 ...

  7. 201521123115《Java程序设计》第14周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多数据库相关内容. 2. 书面作业 1. MySQL数据库基本操作 建立数据库,将自己的姓名.学号作为一条记录插入.(截图,需出现自 ...

  8. request.getParameter()获取URL中文参数乱码的解决办法

    这个问题耽误好长时间,URL传中文参数出现乱码,就算首次使用request接收就添加 request.setCharacterEncoding("UTf-8"); 依然报错不误. ...

  9. AJAX验证码检查

    前言 对于验证码检查我们并不会陌生,我们在学习Session的时候已经使用过了验证码检查了.详细可参考:http://blog.csdn.net/hon_3y/article/details/5479 ...

  10. 通过Xshell登录远程服务器实时查看log日志

    主要想总结以下几点: 1.如何使用生成密钥的方式来登录Xshell连接远端服务器 2.在远程服务器上如何上传和下载文件(下载log文件到本地) 3.如何实时查看log,提取错误信息 一.  使用生成密 ...