Python Tkinter 标准会话
来源:互联网 发布:知乎 电力电子就业方向 编辑:程序博客网 时间:2024/05/16 14:05
Standard Dialogs
Before we look at what to put in that application work area, let’s take a look at another important part of GUI programming: displaying dialogs and message boxes.
在思考往程序的工作区放置什么之前,让我们先看一下GUI编程中另外一个很重要的部分:展示会话和消息框
Starting with Tk 4.2, the Tk library provides a set of standard dialogs that can be used to display message boxes, and to select files and colors. In addition, Tkinter provides some simple dialogs allowing you to ask the user for integers, floating point values, and strings. Where possible, these standard dialogs use platform-specific mechanisms, to get the right look and feel.
从Tk4.2开始,Tk库就提供了一系列的标准会话用于展示消息框、选择文件和颜色。此外,Tkinter提供了一些简单的会话从用户去请求整数值、浮点值和字符串。这些标准会话使用平台特殊机制,从而尽可能的保障合适的外观和感觉。
Message Boxes
The tkMessageBox module provides an interface to the message dialogs.
tkMessageBox模块提供一个消息会话的接口。
The easiest way to use this module is to use one of the convenience functions: showinfo, showwarning, showerror, askquestion,askokcancel, askyesno, or askretrycancel. They all have the same syntax:
使用这个模块的最简单的方式就是去使用那些方便的函数:showinfo, showwarnning, showerror, askquestion, askokcancel, askyesno, 或者askretrycancel. 它们拥有一样的语法:
tkMessageBox.function(title, message [, options]).
The title argument is shown in the window title, and the message in the dialog body. You can use newline characters (“\n”) in the message to make it occupy multiple lines. The options can be used to modify the look; they are explained later in this section.
参数title显示在窗口标题栏,参数message被显示在会话主体。在message中使用换行符("\n")可以使用多行。options参数可以用来修改外观,稍后的章节中会做相关的介绍。
The first group of standard dialogs is used to present information. You provide the title and the message, the function displays these using an appropriate icon, and returns when the user has pressed OK. The return value should be ignored.
第一类标准会话框用于展示信息。这个函数将会使用一个合适的图标去展示title和message,当用户按下OK以后返回,返回值则被忽略。
Here’s an example:
这里有一个例子。
The second group is used to ask questions. The askquestion function returns the strings “yes” or “no” (you can use options to modify the number and type of buttons shown), while the others return a true value of the user gave a positive answer (ok, yes, and retry, respectively).
第二类被用于询问问题。askquestion函数返回字符串'yes'或者'no'(可以使用options参数去修改按钮的数目和类型),而其他的函数会在用户给出一个积极答案(ok,yes和retry)的时候返回一个真值
[Screenshots made on a Swedish version of Windows 95. Hope you don’t mind…]
Message Box 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 message and title are usually given as arguments, not as options).
如果标准消息框是不合适的,可以选择最恰当的,并使用options参数去修改它从而满足的需求。下面的options可供选择(注意message和title通常用作参数,而非options)
default (constant)
Which button to make default: ABORT, RETRY, IGNORE, OK, CANCEL,YES, or NO (the constants are defined in the tkMessageBox module).
icon (constant)
Which icon to display: ERROR, INFO, QUESTION, 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:ABORTRETRYIGNORE, OK, OKCANCEL, RETRYCANCEL, YESNO, or YESNOCANCEL.
- Python Tkinter 标准会话
- Python Tkinter 会话窗口
- Python Tkinter Hello,Tkinter
- python tkinter
- python:Tkinter
- Python Tkinter
- 小白学tkinter(标准对话框)
- 基于Python的标准库tkinter创建面向对象的GUI应用程序
- Python Tkinter的HelloWorld
- Python GUI (Tkinter)
- Python + Tkinter画树
- python Tkinter例子
- Python之Tkinter:动作
- Python之Tkinter:动作
- Python Tkinter PanedWindow 控件
- Python Tkinter Radiobutton控件
- Python Tkinter Scrollbar控件
- Python Tkinter Spinbox控件
- C/C++学习笔记7:const运用(2)之const成员函数
- Plesk控制面板的优点
- HDU 2191 珍惜现在,感恩生活(多重背包)
- 【九度OJ】1100【Dijkstra】
- Phpstorm智能和快速的PHP IDE
- Python Tkinter 标准会话
- ExtJs给textfield赋值
- PHP培训navneet夏尔马
- Android的单位及屏幕分辨率
- Criteria的完整用法
- 静态常量与非静态常量的关系(static const 与const)
- c语言 判断ip是否合法的简单例子
- PC到电话的解决方案 - 以沟通的一个新的水平
- Spring3拦截引发的问题——WEB开发中的客户端路径