An Introduction to Tkinter
前页 | Chapter 40. The Scrollbar Widget | 后页

# Options

The `Scrollbar` widget supports the following options.

Note that most options are ignored on Windows and Macintosh, where the scrollbar is drawn via the native UI toolkit. For best results, use only the `command` and `orient` options in your programs.

Table 40-1. Scrollbar Options

Option | Type | Description
--- | --- | ---
`orient` | constant | Defines how to draw the scrollbar. Use one of `HORIZONTAL` or `VERTICAL`. Default is `VERTICAL`.
`command` | callback | Used to update the associated widget. This is typically the `xview` or `yview` method of the scrolled widget. If the user drags the scrollbar slider, the command is called as `callback(MOVETO, offset)`, where offset 0.0 means that the slider is in its topmost (or leftmost) position, and offset 1.0 means that it is in its bottommost (or rightmost) position.

If the user clicks the arrow buttons, or clicks in the trough, the command is called as `callback(SCROLL, step, what)`. The second argument is either "`-1`" or "`1`" depending on the direction, and the third argument is `UNITS` to scroll lines (or other units relevant for the scrolled widget), or `PAGES` to scroll full pages.

These constants are not defined in Python 1.5.2 and earlier. For compatibility, use the strings "`moveto`", "`scroll`", "`units`", and "`pages`"instead.

`activebackground` | color |
`activerelief` | constant |
`background (bg)` | color |
`cursor` | cursor | The cursor to show when the mouse pointer is placed over the scrollbar widget. Default is a system specific arrow cursor.
`elementborderwidth` | distance |
`highlightbackground, highlightcolor` | color | Controls how to draw the focus highlight border. When the widget has focus, the border is drawn in the `highlightcolor` color. Otherwise, it is drawn in the `highlightbackground` color. The defaults are system specific.
`highlightthickness` | distance | Controls the width of the focus highlight border. Default is 0 (no border). Note that this option is ignored under Windows.
`jump` | constant |
`relief` | constant | Border decoration. The default is `SUNKEN`. Other possible values are `FLAT`, `RAISED`, `GROOVE`, and `RIDGE`. Note that this option is ignored under Windows.
`borderwidth (bd)` | distance | Border width. The default is 0 (no border). Note that this option is ignored under Windows.
`repeatdelay` | time |
`repeatinterval` | time |
`takefocus` | flag | Indicates that the user can use the Tab key to move to this widget. Default is an empty string, which means that the scrollbar accepts focus only if it has any keyboard bindings (default is off, in other words).
`troughcolor` | color |
`width` | distance |

前页 | Home | 后页
Methods | Up | The StringVar Class