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 %