Gtk.ScaleButton

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.AccessibleRange Gtk.AccessibleRange GObject.GInterface->Gtk.AccessibleRange Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget Gtk.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.ScaleButton Gtk.ScaleButton Gtk.AccessibleRange->Gtk.ScaleButton Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Orientable->Gtk.ScaleButton Gtk.Widget->Gtk.ScaleButton

Subclasses:

Gtk.VolumeButton

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Orientable (2)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new (min, max, step, icons)

get_active ()

get_adjustment ()

get_minus_button ()

get_plus_button ()

get_popup ()

get_value ()

set_adjustment (adjustment)

set_icons (icons)

set_value (value)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.AccessibleRange (1)

do_value_changed (value)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1), Gtk.Orientable (1)

Name

Type

Flags

Short Description

active

bool

r

adjustment

Gtk.Adjustment

r/w/en

icons

[str]

r/w

value

float

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

popdown

Emitted to dismiss the popup.

popup

Emitted to popup the scale widget.

value-changed

Emitted when the value field has changed.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gtk.Widget

r

Class Details

class Gtk.ScaleButton(**kwargs)
Bases:

Gtk.Widget, Gtk.AccessibleRange, Gtk.Orientable

Abstract:

No

Structure:

Gtk.ScaleButtonClass

GtkScaleButton 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 [class`Gtk`.VolumeButton] subclass that is tailored for this use case.

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.

classmethod new(min, max, step, icons)[source]
Parameters:
  • min (float) – the minimum value of the scale (usually 0)

  • max (float) – the maximum value of the scale (usually 100)

  • step (float) – the stepping of value when a scroll-wheel event, or up/down arrow event occurs (usually 2)

  • icons ([str] or None) – a None-terminated array of icon names, or None if you want to set the list later with Gtk.ScaleButton.set_icons()

Returns:

a new GtkScaleButton

Return type:

Gtk.Widget

Creates a GtkScaleButton.

The new scale button has a range between min and max, with a stepping of step.

get_active()[source]
Returns:

whether the button is pressed

Return type:

bool

Queries a GtkScaleButton and returns its current state.

Returns True if the scale button is pressed in and False if it is raised.

New in version 4.10.

get_adjustment()[source]
Returns:

the adjustment associated with the scale

Return type:

Gtk.Adjustment

Gets the GtkAdjustment associated with the GtkScaleButton’s scale.

See [method`Gtk`.Range.get_adjustment] for details.

get_minus_button()[source]
Returns:

the minus button of the GtkScaleButton

Return type:

Gtk.Button

Retrieves the minus button of the GtkScaleButton.

get_plus_button()[source]
Returns:

the plus button of the GtkScaleButton

Return type:

Gtk.Button

Retrieves the plus button of the GtkScaleButton.

get_popup()[source]
Returns:

the popup of the GtkScaleButton

Return type:

Gtk.Widget

Retrieves the popup of the GtkScaleButton.

get_value()[source]
Returns:

current value of the scale button

Return type:

float

Gets the current value of the scale button.

set_adjustment(adjustment)[source]
Parameters:

adjustment (Gtk.Adjustment) – a GtkAdjustment

Sets the GtkAdjustment to be used as a model for the GtkScaleButton’s scale.

See [method`Gtk`.Range.set_adjustment] for details.

set_icons(icons)[source]
Parameters:

icons ([str]) – a None-terminated array of icon names

Sets the icons to be used by the scale button.

set_value(value)[source]
Parameters:

value (float) – new value of the scale button

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 [signal`Gtk`.ScaleButton::value-changed] signal if the value changes.

do_value_changed(value) virtual
Parameters:

value (float) –

Signal Details

Gtk.ScaleButton.signals.popdown(scale_button)
Signal Name:

popdown

Flags:

RUN_LAST, ACTION

Parameters:

scale_button (Gtk.ScaleButton) – The object which received the signal

Emitted to dismiss the popup.

This is a keybinding signal.

The default binding for this signal is <kbd>Escape</kbd>.

Gtk.ScaleButton.signals.popup(scale_button)
Signal Name:

popup

Flags:

RUN_LAST, ACTION

Parameters:

scale_button (Gtk.ScaleButton) – The object which received the signal

Emitted to popup the scale widget.

This is a keybinding signal.

The default bindings for this signal are <kbd>Space</kbd>, <kbd>Enter</kbd> and <kbd>Return</kbd>.

Gtk.ScaleButton.signals.value_changed(scale_button, value)
Signal Name:

value-changed

Flags:

RUN_LAST

Parameters:
  • scale_button (Gtk.ScaleButton) – The object which received the signal

  • value (float) – the new value

Emitted when the value field has changed.

Property Details

Gtk.ScaleButton.props.active
Name:

active

Type:

bool

Default Value:

False

Flags:

READABLE

If the scale button should be pressed in.

New in version 4.10.

Gtk.ScaleButton.props.adjustment
Name:

adjustment

Type:

Gtk.Adjustment

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The GtkAdjustment that is used as the model.

Gtk.ScaleButton.props.icons
Name:

icons

Type:

[str]

Default Value:

[]

Flags:

READABLE, WRITABLE

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 icons array, it will be used for all the values. If only two icon names are in the icons array, 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 GtkScaleButton reflects the current value of the scale better for the users.

Gtk.ScaleButton.props.value
Name:

value

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The value of the scale.