python中tkinter模块_tkinter --- Tcl/Tk的Python接口 — Python 3.8.6 文档

Setting Options¶

Options control things like the color and border width of a widget. Options can

be set in three ways:

At object creation time, using keyword argumentsfred = Button(self, fg="red", bg="blue")

After object creation, treating the option name like a dictionary indexfred["fg"] = "red"

fred["bg"] = "blue"

Use the config() method to update multiple attrs subsequent to object creationfred.config(fg="red", bg="blue")

For a complete explanation of a given option and its behavior, see the Tk man

pages for the widget in question.

Note that the man pages list "STANDARD OPTIONS" and "WIDGET SPECIFIC OPTIONS"

for each widget. The former is a list of options that are common to many

widgets, the latter are the options that are idiosyncratic to that particular

widget. The Standard Options are documented on the

No distinction between standard and widget-specific options is made in this

document. Some options don't apply to some kinds of widgets. Whether a given

widget responds to a particular option depends on the class of the widget;

buttons have a command option, labels do not.

The options supported by a given widget are listed in that widget's man page, or

can be queried at runtime by calling the config() method without

arguments, or by calling the keys() method on that widget. The return

value of these calls is a dictionary whose key is the name of the option as a

string (for example, 'relief') and whose values are 5-tuples.

Some options, like bg are synonyms for common options with long names

(bg is shorthand for "background"). Passing the config() method the name

of a shorthand option will return a 2-tuple, not 5-tuple. The 2-tuple passed

back will contain the name of the synonym and the "real" option (such as

('bg', 'background')).

索引

含义

示例

0

选项名称

'relief'

1

数据库查找的选项名称

'relief'

2

数据库查找的选项类

'Relief'

3

默认值

'raised'

4

当前值

'groove'

示例:

>>>print(fred.config())

{'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')}

Of course, the dictionary printed will include all the options available and

their values. This is meant only as an example.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值