Next / Previous / Contents / TCC Help System / NM Tech homepage

41. ttk.Scale

This is the ttk version of Section 21, “The Scale widget”. To create a ttk.Scale widget as the child of a given parent widget, where the option values are given in Table 57, “ttk.Scale options”:

    w = ttk.Scale(parent, option=value, ...)

Table 57. ttk.Scale options

class_ The widget class name. This may be specified when the widget is created, but cannot be changed later. For an explanation of widget classes, see Section 27, “Standardizing appearance”.
command A function to be called whenever the state of this widget changes. This function will receive one argument, the new value shown on the widget, as a float.
cursor The cursor that will appear when the mouse is over the scale; see Section 5.8, “Cursors”.
from_ Use this option in combination with the to option (described below) to constrain the values to a numeric range. For example, from_=-10 and to=10 would allow only values between −10 and 20 inclusive. See also the increment option below.
length The length of the scale widget. This is the x dimension if the scale is horizontal, or the y dimension if vertical. The default is 100 pixels. For allowable values, see Section 5.1, “Dimensions”.
orient Set orient=tk.HORIZONTAL if you want the scale to run along the x dimension, or orient=tk.VERTICAL to run parallel to the y-axis. Default is vertical.
style The style to be used in rendering this radiobutton; see Section 49, “Using and customizing ttk styles”.
takefocus By default, a ttk.Scale widget will be included in focus traversal; see Section 53, “Focus: routing keyboard input”. To remove the widget from focus traversal, use takefocus=False.
to A float value that defines one end of the scale's range; the other end is defined by the from_ option, discussed above. The to value can be either greater than or less than the from_ value. For vertical scales, the to value defines the bottom of the scale; for horizontal scales, the right end. The default value is 100.
value Use this option to set the initial value of the widget's variable; the default is 0.0.
variable Use this option to associate a control variable with the widget. Typically this will be a tk.DoubleVar instance, which holds a value of type float. You may instead use a tk.IntVar instance, but values stored in it will be truncated as type int.

These options of the Tkinter Scale widget are not supported by the ttk.Scale widget constructor:

Table 58. Tkinter Scale options not in ttk.Scale

activebackground Use a style map to control the background option; see Section 50.2, “ttk style maps: dynamic appearance changes”.
background or bg Configure the background option using a style; this option controls the color of the slider. The bg abbreviation is not supported.
borderwidth or bd Configure this option using a style.
digits Not supported.
font Not supported.
foreground or fg Not supported.
highlightbackground Not supported.
highlightcolor Not supported.
highlightthickness Not supported.
label Not supported.
relief Not supported.
repeatdelay Not supported.
repeatinterval Not supported.
resolution Not supported.
showvalue Not supported.
sliderlength Configure this option using a style.
sliderrelief Configure this option using a style.
state In ttk, there is no option with this name. The state mechanism has been generalized; see Section 50.2, “ttk style maps: dynamic appearance changes”.
tickinterval Not supported.
troughcolor Configure this option using a style.
width Configure this option using the sliderthickness option in a style.

Methods on a ttk.Scale include all those described in Section 46, “Methods common to all ttk widgets”, plus:


Returns the current value shown on the widget.


Change the widget's current value to newValue.