Tk 通用选项

Tk widgets 支持很多有关显示和动作的选项。一般的,默认值是比较合理的,我们不会去特别的设定它的值。但喜欢自定义的,还是有必要知道这些widgets的通用选项:

 

-background color    The background color for a widget.
-borderwidth width The width of the border to be drawn around widgets with 3D effects.
-font fontDescriptor The font to use for widgets that display text.

-foreground color     The foreground color for a widget. This is the color in which text will  be drawn in a text widget or on a label. It acceptsthe same color names and descriptions as  -background.
-height number The requested height of the widget in pixels.
-highlightbackground color The color rectangle to draw around a widget when the widget does not have input focus.
-highlightcolor color The color rectangle to draw around a widget when the widget has input focus.
-padx number
-pady number
The -padx and -pady options request extra space (in pixels) to be placed around the widgets when they are arranged in another widget or in the main window.
-relief condition The 3D relief for this widget: condition may be raised , sunken , flat , ridge , solid , or groove .
-text text The text to display in this widget.
-textvariable varName The name of a variable to associate with this widget. The content of the variable will reflect the content of the widget. For example, the textvariable associated with an entry widget will contain the characters typed into the entry widget.
-width number The requested width of the widget in pixels.

 

也可以在交互式命令行里得到比如Button的选项:

 

(DELL) 57 % button .e
.e
(DELL) 58 % puts [join [.e configure] "/n"]
-activebackground activeBackground Foreground SystemButtonFace SystemButtonFace
-activeforeground activeForeground Background SystemButtonText SystemButtonText
-anchor anchor Anchor center center
-background background Background SystemButtonFace SystemButtonFace
-bd -borderwidth
-bg -background
-bitmap bitmap Bitmap {} {}
-borderwidth borderWidth BorderWidth 2 2
-command command Command {} {}
-compound compound Compound none none
-cursor cursor Cursor {} {}
-default default Default disabled disabled
-disabledforeground disabledForeground DisabledForeground SystemDisabledText SystemDisabledText
-fg -foreground
-font font Font TkDefaultFont TkDefaultFont
-foreground foreground Foreground SystemButtonText SystemButtonText
-height height Height 0 0
-highlightbackground highlightBackground HighlightBackground SystemButtonFace SystemButtonFace
-highlightcolor highlightColor HighlightColor SystemWindowFrame SystemWindowFrame
-highlightthickness highlightThickness HighlightThickness 1 1
-image image Image {} {}
-justify justify Justify center center
-overrelief overRelief OverRelief {} {}
-padx padX Pad 1 1
-pady padY Pad 1 1
-relief relief Relief raised raised
-repeatdelay repeatDelay RepeatDelay 0 0
-repeatinterval repeatInterval RepeatInterval 0 0
-state state State normal normal
-takefocus takeFocus TakeFocus {} {}
-text text Text {} {}
-textvariable textVariable Variable {} {}
-underline underline Underline -1 -1
-width width Width 0 0
-wraplength wrapLength WrapLength 0 0
(DELL) 59 %

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值