ttk::scrollbar(n)
β¨ NAME β¨
ttk::scrollbar β control the viewport of a scrollable widget. This is the ttk::scrollbar(n) page, and yes bestie, itβs giving Tk Themed Widget energy from the jump π.
π¦ SYNOPSIS π¦
ttk::scrollbar pathName ?options...?
πΈ DESCRIPTION πΈ
okay so ttk::scrollbar widgets are typically linked to an associated window that displays a document of some sort β like a file being edited or a drawing π¨. A scrollbar displays a thumb in the middle portion of the scrollbar, and that thumbβs position and size give you info about the portion of the document thatβs visible in the associated window. lowkey iconic.
The thumb may be dragged by the user to control the visible region πβ¨. Depending on the theme, two or more arrow buttons may also be present; these are used to scroll the visible region in discrete units. cute, functional, fr fr.
π STANDARD OPTIONS π
-class-cursor-style-takefocus
See the ttk_widget manual entry for details on the standard options.
π WIDGET-SPECIFIC OPTIONS π
π§Έ -command
- Command-Line Name:
-command - Database Name:
command - Database Class:
Command
A Tcl script prefix that gets evaluated to change the view in the widget associated with the scrollbar. Additional arguments are appended to the value of this option, as described in SCROLLING COMMANDS below, whenever the user requests a view change by manipulating the scrollbar.
This option typically consists of a two-element list, containing the name of a scrollable widget followed by either xview (for horizontal scrollbars) or yview (for vertical scrollbars). periodt.
π§Έ -orient
- Command-Line Name:
-orient - Database Name:
orient - Database Class:
Orient
One of horizontal or vertical. Specifies the orientation of the scrollbar. no cap.
π«Ά WIDGET COMMAND π«Ά
In addition to the standard cget, configure, identify element, instate, state and style commands (see ttk::widget), scrollbar widgets support the following additional commands:
π pathName get
Hands back the scrollbar settings as a list whose elements are the arguments to the most recent set widget command.
π pathName set first last
This command is normally invoked by the scrollbarβs associated widget from an -xscrollcommand or -yscrollcommand callback. Specifies the visible range to be displayed. first and last are real fractions between 0 and 1.
π₯ INTERNAL COMMANDS π₯
The following widget commands are used internally by the TScrollbar widget class bindings.
bestie heads up: these are internal β the TScrollbar widget class bindings are the ones using them, iykyk π
π§ pathName delta deltaX deltaY
Returns a real number indicating the fractional change in the scrollbar setting that corresponds to a given change in thumb position. For example, if the scrollbar is horizontal, the result indicates how much the scrollbar setting must change to move the thumb deltaX pixels to the right (deltaY is ignored in this case). If the scrollbar is vertical, the result indicates how much the scrollbar setting must change to move the thumb deltaY pixels down. The arguments and the result may be zero or negative.
π§ pathName fraction x y
Returns a real number between 0 and 1 indicating where the point given by x and y lies in the trough area of the scrollbar, where 0.0 corresponds to the top or left of the trough and 1.0 corresponds to the bottom or right. X and y are pixel coordinates relative to the scrollbar widget. If x and y refer to a point outside the trough, the closest point in the trough is used.
π SCROLLING COMMANDS π
When the user interacts with the scrollbar β for example by dragging the thumb β the scrollbar notifies the associated widget that it must change its view. The scrollbar makes the notification by evaluating a Tcl command generated from the scrollbarβs -command option. The command may take any of the following forms. In each case, prefix is the contents of the -command option, which usually has a form like .t yview.
β prefix moveto fraction
fraction is a real number between 0 and 1. The widget should adjust its view so that the point given by fraction appears at the beginning of the widget. If fraction is 0 it refers to the beginning of the document. 1.0 refers to the end of the document, 0.333 refers to a point one-third of the way through the document, and so on. math girlie behavior π.
β prefix scroll number pages
The widget should adjust its view by number pages. It is up to the widget to define the meaning of a page; typically it is slightly less than what fits in the window, so that there is a slight overlap between the old and new views. Number is either 1, which means the next page should become visible, or -1, which means that the previous page should become visible.
β prefix scroll number units
The widget should adjust its view by number units. The units are defined in whatever way makes sense for the widget, such as characters or lines in a text widget. Number is either 1, which means one unit should scroll off the top or left of the window, or -1, which means that one unit should scroll off the bottom or right of the window.
π WIDGET STATES π
The scrollbar automatically sets the disabled state bit when the entire range is visible (range is 0.0 to 1.0), and clears it otherwise. It also sets the active and pressed state flags of individual elements, based on the position and state of the mouse pointer.
π EXAMPLE π
hereβs the whole setup, bestie β copy-paste approved π«Ά:
set f [frame .f]
ttk::scrollbar $f.hsb -orient horizontal -command [list $f.t xview]
ttk::scrollbar $f.vsb -orient vertical -command [list $f.t yview]
text $f.t -xscrollcommand [list $f.hsb set] -yscrollcommand [list $f.vsb set]
grid $f.t -row 0 -column 0 -sticky nsew
grid $f.vsb -row 0 -column 1 -sticky nsew
grid $f.hsb -row 1 -column 0 -sticky nsew
grid columnconfigure $f 0 -weight 1
grid rowconfigure $f 0 -weight 1
pack $f
π STYLING OPTIONS π
The class name for a ttk::scrollbar is TScrollbar.
Dynamic states: active, disabled.
TScrollbar (or more specifically Vertical.TScrollbar and Horizontal.TScrollbar) styling options that are configurable with ttk::style are:
-arrowcolor color-arrowsize amount-background color-bordercolor color-darkcolor colorβ color of the dark part of the 3D relief-foreground color-gripsize sizeβ number of screen units-lightcolor colorβ color of the light part of the 3D relief-troughcolor color
Some options are only available for specific themes.
See the ttk::style manual page for information on how to configure ttk styles.
π¦ SEE ALSO π¦
ttk::widget(n)scrollbar(n)
π KEYWORDS π
scrollbarwidget
okay thatβs the whole manual, bestie β much love from Tk 8.5 and the ttk::scrollbar(n) page π
β¨π«Ά
π¦ where this page comes from
- alpine 3.23: tk9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tk9-doc 9.0.3-r2 Β· TCL
- fedora 43: tk 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 43: tk 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- nixos 26.05: tk 9.0.3
- nixpkgs unstable: tk 9.1.0
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- Copyright (c) 2004 Joe English
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms