1ttk::scrollbar(n) Tk Themed Widget ttk::scrollbar(n)
2
3
4
5______________________________________________________________________________
6
8 ttk::scrollbar - Control the viewport of a scrollable widget
9
11 ttk::scrollbar pathName ?options...?
12_________________________________________________________________
13
15 ttk::scrollbar widgets are typically linked to an associated window
16 that displays a document of some sort, such as a file being edited or a
17 drawing. A scrollbar displays a thumb in the middle portion of the
18 scrollbar, whose position and size provides information about the por‐
19 tion of the document visible in the associated window. The thumb may
20 be dragged by the user to control the visible region. Depending on the
21 theme, two or more arrow buttons may also be present; these are used to
22 scroll the visible region in discrete units.
23
25 -class -cursor -style
26 -takefocus
27
28 See the ttk_widget manual entry for details on the standard options.
29
31 [-command command] A Tcl script prefix to evaluate to change the view
32 in the widget associated with the scrollbar. Additional arguments are
33 appended to the value of this option, as described in SCROLLING COM‐
34 MANDS below, whenever the user requests a view change by manipulating
35 the scrollbar.
36
37 This option typically consists of a two-element list, containing
38 the name of a scrollable widget followed by either xview (for
39 horizontal scrollbars) or yview (for vertical scrollbars).
40 [-orient orient] One of horizontal or vertical. Specifies the orienta‐
41 tion of the scrollbar.
42
44 pathName cget option
45 Returns the current value of the specified option; see ttk::wid‐
46 get(n).
47
48 pathName configure ?option? ?value option value ...?
49 Modify or query widget options; see ttk::widget(n).
50
51 pathName get
52 Returns the scrollbar settings in the form of a list whose ele‐
53 ments are the arguments to the most recent set widget command.
54
55 pathName identify x y
56 Returns the name of the element at position x, y. See ttk::wid‐
57 get(n).
58
59 pathName instate statespec ?script?
60 Test the widget state; see ttk::widget(n).
61
62 pathName set first last
63 This command is normally invoked by the scrollbar's associated
64 widget from an -xscrollcommand or -yscrollcommand callback.
65 Specifies the visible range to be displayed. first and last are
66 real fractions between 0 and 1.
67
68 pathName state ?stateSpec?
69 Modify or query the widget state; see ttk::widget(n).
70
72 The following widget commands are used internally by the TScrollbar
73 widget class bindings.
74
75 pathName delta deltaX deltaY
76 Returns a real number indicating the fractional change in the
77 scrollbar setting that corresponds to a given change in thumb
78 position. For example, if the scrollbar is horizontal, the
79 result indicates how much the scrollbar setting must change to
80 move the thumb deltaX pixels to the right (deltaY is ignored in
81 this case). If the scrollbar is vertical, the result indicates
82 how much the scrollbar setting must change to move the thumb
83 deltaY pixels down. The arguments and the result may be zero or
84 negative.
85
86 pathName fraction x y
87 Returns a real number between 0 and 1 indicating where the point
88 given by x and y lies in the trough area of the scrollbar, where
89 0.0 corresponds to the top or left of the trough and 1.0 corre‐
90 sponds to the bottom or right. X and y are pixel coordinates
91 relative to the scrollbar widget. If x and y refer to a point
92 outside the trough, the closest point in the trough is used.
93
95 When the user interacts with the scrollbar, for example by dragging the
96 thumb, the scrollbar notifies the associated widget that it must change
97 its view. The scrollbar makes the notification by evaluating a Tcl
98 command generated from the scrollbar's -command option. The command
99 may take any of the following forms. In each case, prefix is the con‐
100 tents of the -command option, which usually has a form like .t yview
101
102 prefix moveto fraction
103 Fraction is a real number between 0 and 1. The widget should
104 adjust its view so that the point given by fraction appears at
105 the beginning of the widget. If fraction is 0 it refers to the
106 beginning of the document. 1.0 refers to the end of the docu‐
107 ment, 0.333 refers to a point one-third of the way through the
108 document, and so on.
109
110 prefix scroll number units
111 The widget should adjust its view by number units. The units
112 are defined in whatever way makes sense for the widget, such as
113 characters or lines in a text widget. Number is either 1, which
114 means one unit should scroll off the top or left of the window,
115 or -1, which means that one unit should scroll off the bottom or
116 right of the window.
117
118 prefix scroll number pages
119 The widget should adjust its view by number pages. It is up to
120 the widget to define the meaning of a page; typically it is
121 slightly less than what fits in the window, so that there is a
122 slight overlap between the old and new views. Number is either
123 1, which means the next page should become visible, or -1, which
124 means that the previous page should become visible.
125
127 The scrollbar automatically sets the disabled state bit. when the
128 entire range is visible (range is 0.0 to 1.0), and clears it otherwise.
129 It also sets the active and pressed state flags of individual elements,
130 based on the position and state of the mouse pointer.
131
133 set f [frame .f]
134 ttk::scrollbar $f.hsb -orient horizontal -command [list $f.t xview]
135 ttk::scrollbar $f.vsb -orient vertical -command [list $f.t yview]
136 text $f.t -xscrollcommand [list $f.hsb set] -yscrollcommand [list $f.vsb set]
137 grid $f.t -row 0 -column 0 -sticky nsew
138 grid $f.vsb -row 0 -column 1 -sticky nsew
139 grid $f.hsb -row 1 -column 0 -sticky nsew
140 grid columnconfigure $f 0 -weight 1
141 grid rowconfigure $f 0 -weight 1
142
144 ttk::widget(n), scrollbar(n)
145
147 scrollbar, widget
148
149
150
151Tk 8.5 ttk::scrollbar(n)