Skip to content

LabeledScale

Bases: Frame

A horizontal scale widget with a label showing the current value.

The label automatically updates to display the current value and follows the slider position. Only horizontal orientation is currently supported.

Attributes:

Name Type Description
scale Scale

The underlying Scale widget.

label Label

The Label widget displaying the current value.

value property writable

value: int | float

Get the current scale value.

Returns:

Type Description
int | float

The current value of the scale as an int or float.

__init__

__init__(
    master: Master = None,
    value: int | float = 0,
    minvalue: int | float = 0,
    maxvalue: int | float = 100,
    variable: Variable = None,
    dtype: type[int] | type[float] = int,
    compound: Literal["before", "after"] = "before",
    accent: str = None,
    **kwargs: Any,
)

Create a horizontal labeled scale widget.

The widget combines a Scale and Label in a Frame, with the label positioned either above or below the scale based on the compound parameter. The label automatically tracks the slider position and displays the current value.

Parameters:

Name Type Description Default
master Master

The parent widget. If None, uses the default root window.

None
value int | float

Initial value for the scale. Defaults to 0.

0
minvalue int | float

Minimum value of the scale range. Maps to the scale's 'from_' parameter. Defaults to 0.

0
maxvalue int | float

Maximum value of the scale range. Maps to the scale's 'to' parameter. Defaults to 100.

100
variable Variable

A tkinter variable to associate with the scale. If None, creates an IntVar or DoubleVar based on dtype. Defaults to None.

None
dtype type[int] | type[float]

Data type for the scale value, either int or float. Determines the type of variable created if variable is None. Defaults to int.

int
compound Literal['before', 'after']

Label position relative to the scale. Use 'before' for label above the scale or 'after' for label below the scale. Defaults to 'before'.

'before'
accent str

Accent token to apply to the scale.

None
**kwargs Any

Additional keyword arguments passed to the Frame constructor. A padding of 2 is forced to provide minimal spacing.

{}

destroy

destroy()

Destroy the widget and clean up the associated variable.