Documentation generated from fossil trunk
ttk::widget -
Standard options and commands supported by Tk themed widgets
This manual describes common widget options and commands.
The following options are supported by all Tk themed widgets:
Name | Database name | Database class |
---|---|---|
-class | undefined | undefined |
Specifies the window class. The class is used when querying the option database for the window's other options, to determine the default bindtags for the window, and to select the widget's default layout and style. This is a read-only option: it may only be specified when the window is created, and may not be changed with the configure widget command. | ||
-cursor | cursor | Cursor |
Specifies the mouse cursor to be used for the widget. See Tk_GetCursor and cursors(n) in the Tk reference manual for the legal values. If set to the empty string (the default), the cursor is inherited from the parent widget. | ||
-takefocus | takeFocus | TakeFocus |
Determines whether the window accepts the focus during keyboard traversal. Either 0, 1, a command prefix (to which the widget path is appended, and which should return 0 or 1), or the empty string. See options(n) in the Tk reference manual for the full description. | ||
-style | style | Style |
May be used to specify a custom widget style. |
The following options are supported by widgets that are controllable by a scrollbar. See scrollbar(n) for more information
Name | Database name | Database class |
---|---|---|
-xscrollcommand | xScrollCommand | ScrollCommand |
A command prefix, used to communicate with horizontal scrollbars.
When the view in the widget's window changes, the widget will generate a Tcl command by concatenating the scroll command and two numbers. Each of the numbers is a fraction between 0 and 1 indicating a position in the document; 0 indicates the beginning, and 1 indicates the end. The first fraction indicates the first information in the widget that is visible in the window, and the second fraction indicates the information just after the last portion that is visible. Typically the -xscrollcommand option consists of the path name of a scrollbar widget followed by "set", e.g. ".x.scrollbar set". This will cause the scrollbar to be updated whenever the view in the window changes. If this option is set to the empty string (the default), then no command will be executed. | ||
-yscrollcommand | yScrollCommand | ScrollCommand |
A command prefix, used to communicate with vertical scrollbars. See the description of -xscrollcommand above for details. |
The following options are supported by labels, buttons, and other button-like widgets:
Name | Database name | Database class |
---|---|---|
-text | text | Text |
Specifies a text string to be displayed inside the widget (unless overridden by -textvariable). | ||
-textvariable | textVariable | Variable |
Specifies the name of a global variable whose value will be used in place of the -text resource. | ||
-underline | underline | Underline |
If set, specifies the integer index (0-based) of a character to underline in the text string. The underlined character is used for mnemonic activation. | ||
-image | image | Image |
Specifies an image to display. This is a list of 1 or more elements. The first element is the default image name. The rest of the list is a sequence of statespec / value pairs as per style map, specifying different images to use when the widget is in a particular state or combination of states. All images in the list should have the same size. | ||
-compound | compound | Compound |
Specifies how to display the image relative to the text,
in the case both -text and -image are present.
Valid values are:
| ||
-width | width | Width |
If greater than zero, specifies how much space, in character widths, to allocate for the text label. If less than zero, specifies a minimum width. If zero or unspecified, the natural width of the text label is used. |
Name | Database name | Database class |
---|---|---|
-state | state | State |
May be set to normal or disabled to control the disabled state bit. This is a write-only option: setting it changes the widget state, but the state widget command does not affect the -state option. |
if {[pathName instate stateSpec]} script
Returns a new state spec indicating which flags were changed:
set changes [pathName state spec] pathName state $changes
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.
The widget state is a bitmap of independent state flags. Widget state flags include:
A state specification or stateSpec is a list of state names, optionally prefixed with an exclamation point (!) indicating that the bit is off.
set b [ttk::button .b] # Disable the widget: $b state disabled # Invoke the widget only if it is currently pressed and enabled: $b instate {pressed !disabled} { .b invoke } # Reenable widget: $b state !disabled
ttk::intro(n), ttk::style(n)