ScaleButton#
Superclasses: Widget, InitiallyUnowned, Object
Subclasses: VolumeButton
Implemented Interfaces: Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable
Provides a button which pops up a scale widget.
This kind of widget is commonly used for volume controls in multimedia
applications, and GTK provides a VolumeButton subclass that
is tailored for this use case.
Shortcuts and Gestures#
The following signals have default keybindings:
CSS nodes#
scalebutton.scale
╰── button.toggle
╰── <icon>
GtkScaleButton has a single CSS node with name scalebutton and .scale
style class, and contains a button node with a .toggle style class.
Constructors#
- class ScaleButton
- classmethod new(min: float, max: float, step: float, icons: list[str] | None = None) → Widget#
Creates a
GtkScaleButton.The new scale button has a range between
minandmax, with a stepping ofstep.- Parameters:
min – the minimum value of the scale (usually 0)
max – the maximum value of the scale (usually 100)
step – the stepping of value when a scroll-wheel event, or up/down arrow event occurs (usually 2)
icons – a
None-terminated array of icon names, orNoneif you want to set the list later withset_icons()
Methods#
- class ScaleButton
-
- get_active() → bool#
Queries a
GtkScaleButtonand returns its current state.Returns
Trueif the scale button is pressed in andFalseif it is raised.Added in version 4.10.
- get_adjustment() → Adjustment#
Gets the
GtkAdjustmentassociated with theGtkScaleButton’s scale.See
get_adjustmentfor details.
- set_adjustment(adjustment: Adjustment) → None#
Sets the
GtkAdjustmentto be used as a model for theGtkScaleButton’s scale.See
set_adjustmentfor details.- Parameters:
adjustment – a
GtkAdjustment
- set_has_frame(has_frame: bool) → None#
Sets the style of the button.
Added in version 4.14.
- Parameters:
has_frame – whether the button should have a visible frame
- set_icons(icons: list[str]) → None#
Sets the icons to be used by the scale button.
- Parameters:
icons – a
None-terminated array of icon names
- set_value(value: float) → None#
Sets the current value of the scale.
If the value is outside the minimum or maximum range values, it will be clamped to fit inside them.
The scale button emits the
value_changedsignal if the value changes.- Parameters:
value – new value of the scale button
Properties#
- class ScaleButton
-
- props.adjustment: Adjustment#
The
GtkAdjustmentthat is used as the model.
- props.icons: list[str]#
The names of the icons to be used by the scale button.
The first item in the array will be used in the button when the current value is the lowest value, the second item for the highest value. All the subsequent icons will be used for all the other values, spread evenly over the range of values.
If there’s only one icon name in the
iconsarray, it will be used for all the values. If only two icon names are in theiconsarray, the first one will be used for the bottom 50% of the scale, and the second one for the top 50%.It is recommended to use at least 3 icons so that the
GtkScaleButtonreflects the current value of the scale better for the users.
Signals#
- class ScaleButton.signals
- popdown() → None#
Emitted to dismiss the popup.
This is a keybinding signal.
The default binding for this signal is Escape.
- popup() → None#
Emitted to popup the scale widget.
This is a keybinding signal.
The default bindings for this signal are Space, Enter and Return.
Virtual Methods#
Fields#
- class ScaleButton
- parent_instance#