Gtk.Range

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.Range Gtk.Range Gtk.AccessibleRange->Gtk.Range Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Orientable->Gtk.Range Gtk.Widget->Gtk.Range

Subclasses:

Gtk.Scale

Methods

Inherited:

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

Structs:

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

get_adjustment ()

get_fill_level ()

get_flippable ()

get_inverted ()

get_range_rect ()

get_restrict_to_fill_level ()

get_round_digits ()

get_show_fill_level ()

get_slider_range ()

get_slider_size_fixed ()

get_value ()

set_adjustment (adjustment)

set_fill_level (fill_level)

set_flippable (flippable)

set_increments (step, page)

set_inverted (setting)

set_range (min, max)

set_restrict_to_fill_level (restrict_to_fill_level)

set_round_digits (round_digits)

set_show_fill_level (show_fill_level)

set_slider_size_fixed (size_fixed)

set_value (value)

Virtual Methods

Inherited:

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

do_adjust_bounds (new_value)

do_change_value (scroll, new_value)

do_get_range_border (border_)

do_move_slider (scroll)

do_value_changed ()

Properties

Inherited:

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

Name

Type

Flags

Short Description

adjustment

Gtk.Adjustment

r/w/c/en

fill-level

float

r/w/en

inverted

bool

r/w/en

restrict-to-fill-level

bool

r/w/en

round-digits

int

r/w/en

show-fill-level

bool

r/w/en

Signals

Inherited:

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

Name

Short Description

adjust-bounds

Emitted before clamping a value, to give the application a chance to adjust the bounds.

change-value

Emitted when a scroll action is performed on a range.

move-slider

Virtual function that moves the slider.

value-changed

Emitted when the range value changes.

Fields

Inherited:

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

Name

Type

Access

Description

parent_instance

Gtk.Widget

r

Class Details

class Gtk.Range(**kwargs)
Bases:

Gtk.Widget, Gtk.AccessibleRange, Gtk.Orientable

Abstract:

No

Structure:

Gtk.RangeClass

GtkRange is the common base class for widgets which visualize an adjustment.

Widgets that are derived from GtkRange include [class`Gtk`.Scale] and [class`Gtk`.Scrollbar].

Apart from signals for monitoring the parameters of the adjustment, GtkRange provides properties and methods for setting a “fill level” on range widgets. See [method`Gtk`.Range.set_fill_level].

get_adjustment()[source]
Returns:

a GtkAdjustment

Return type:

Gtk.Adjustment

Get the adjustment which is the “model” object for GtkRange.

get_fill_level()[source]
Returns:

The current fill level

Return type:

float

Gets the current position of the fill level indicator.

get_flippable()[source]
Returns:

True if the range is flippable

Return type:

bool

Gets whether the GtkRange respects text direction.

See [method`Gtk`.Range.set_flippable].

get_inverted()[source]
Returns:

True if the range is inverted

Return type:

bool

Gets whether the range is inverted.

See [method`Gtk`.Range.set_inverted].

get_range_rect()[source]
Returns:

return location for the range rectangle

Return type:

range_rect: Gdk.Rectangle

This function returns the area that contains the range’s trough, in coordinates relative to self's origin.

This function is useful mainly for GtkRange subclasses.

get_restrict_to_fill_level()[source]
Returns:

True if self is restricted to the fill level.

Return type:

bool

Gets whether the range is restricted to the fill level.

get_round_digits()[source]
Returns:

the number of digits to round to

Return type:

int

Gets the number of digits to round the value to when it changes.

See [signal`Gtk`.Range::change-value].

get_show_fill_level()[source]
Returns:

True if self shows the fill level.

Return type:

bool

Gets whether the range displays the fill level graphically.

get_slider_range()[source]
Returns:

slider_start:

return location for the slider’s start

slider_end:

return location for the slider’s end

Return type:

(slider_start: int, slider_end: int)

This function returns sliders range along the long dimension, in widget->window coordinates.

This function is useful mainly for GtkRange subclasses.

get_slider_size_fixed()[source]
Returns:

whether the range’s slider has a fixed size.

Return type:

bool

This function is useful mainly for GtkRange subclasses.

See [method`Gtk`.Range.set_slider_size_fixed].

get_value()[source]
Returns:

current value of the range.

Return type:

float

Gets the current value of the range.

set_adjustment(adjustment)[source]
Parameters:

adjustment (Gtk.Adjustment) – a GtkAdjustment

Sets the adjustment to be used as the “model” object for the GtkRange

The adjustment indicates the current range value, the minimum and maximum range values, the step/page increments used for keybindings and scrolling, and the page size.

The page size is normally 0 for GtkScale and nonzero for GtkScrollbar, and indicates the size of the visible area of the widget being scrolled. The page size affects the size of the scrollbar slider.

set_fill_level(fill_level)[source]
Parameters:

fill_level (float) – the new position of the fill level indicator

Set the new position of the fill level indicator.

The “fill level” is probably best described by its most prominent use case, which is an indicator for the amount of pre-buffering in a streaming media player. In that use case, the value of the range would indicate the current play position, and the fill level would be the position up to which the file/stream has been downloaded.

This amount of prebuffering can be displayed on the range’s trough and is themeable separately from the trough. To enable fill level display, use [method`Gtk`.Range.set_show_fill_level]. The range defaults to not showing the fill level.

Additionally, it’s possible to restrict the range’s slider position to values which are smaller than the fill level. This is controlled by [method`Gtk`.Range.set_restrict_to_fill_level] and is by default enabled.

set_flippable(flippable)[source]
Parameters:

flippable (bool) – True to make the range flippable

Sets whether the GtkRange respects text direction.

If a range is flippable, it will switch its direction if it is horizontal and its direction is Gtk.TextDirection.RTL.

See [method`Gtk`.Widget.get_direction].

set_increments(step, page)[source]
Parameters:
  • step (float) – step size

  • page (float) – page size

Sets the step and page sizes for the range.

The step size is used when the user clicks the GtkScrollbar arrows or moves a GtkScale via arrow keys. The page size is used for example when moving via Page Up or Page Down keys.

set_inverted(setting)[source]
Parameters:

setting (bool) – True to invert the range

Sets whether to invert the range.

Ranges normally move from lower to higher values as the slider moves from top to bottom or left to right. Inverted ranges have higher values at the top or on the right rather than on the bottom or left.

set_range(min, max)[source]
Parameters:
  • min (float) – minimum range value

  • max (float) – maximum range value

Sets the allowable values in the GtkRange.

The range value is clamped to be between min and max. (If the range has a non-zero page size, it is clamped between min and max - page-size.)

set_restrict_to_fill_level(restrict_to_fill_level)[source]
Parameters:

restrict_to_fill_level (bool) – Whether the fill level restricts slider movement.

Sets whether the slider is restricted to the fill level.

See [method`Gtk`.Range.set_fill_level] for a general description of the fill level concept.

set_round_digits(round_digits)[source]
Parameters:

round_digits (int) – the precision in digits, or -1

Sets the number of digits to round the value to when it changes.

See [signal`Gtk`.Range::change-value].

set_show_fill_level(show_fill_level)[source]
Parameters:

show_fill_level (bool) – Whether a fill level indicator graphics is shown.

Sets whether a graphical fill level is show on the trough.

See [method`Gtk`.Range.set_fill_level] for a general description of the fill level concept.

set_slider_size_fixed(size_fixed)[source]
Parameters:

size_fixed (bool) – True to make the slider size constant

Sets whether the range’s slider has a fixed size, or a size that depends on its adjustment’s page size.

This function is useful mainly for GtkRange subclasses.

set_value(value)[source]
Parameters:

value (float) – new value of the range

Sets the current value of the range.

If the value is outside the minimum or maximum range values, it will be clamped to fit inside them. The range emits the [signal`Gtk`.Range::value-changed] signal if the value changes.

do_adjust_bounds(new_value) virtual
Parameters:

new_value (float) –

do_change_value(scroll, new_value) virtual
Parameters:
Return type:

bool

do_get_range_border(border_) virtual
Parameters:

border (Gtk.Border) –

do_move_slider(scroll) virtual
Parameters:

scroll (Gtk.ScrollType) –

do_value_changed() virtual

Signal Details

Gtk.Range.signals.adjust_bounds(range, value)
Signal Name:

adjust-bounds

Flags:

RUN_LAST

Parameters:
  • range (Gtk.Range) – The object which received the signal

  • value (float) – the value before we clamp

Emitted before clamping a value, to give the application a chance to adjust the bounds.

Gtk.Range.signals.change_value(range, scroll, value)
Signal Name:

change-value

Flags:

RUN_LAST

Parameters:
  • range (Gtk.Range) – The object which received the signal

  • scroll (Gtk.ScrollType) – the type of scroll action that was performed

  • value (float) – the new value resulting from the scroll action

Returns:

True to prevent other handlers from being invoked for the signal, False to propagate the signal further

Return type:

bool

Emitted when a scroll action is performed on a range.

It allows an application to determine the type of scroll event that occurred and the resultant new value. The application can handle the event itself and return True to prevent further processing. Or, by returning False, it can pass the event to other handlers until the default GTK handler is reached.

The value parameter is unrounded. An application that overrides the ::change-value signal is responsible for clamping the value to the desired number of decimal digits; the default GTK handler clamps the value based on [property`Gtk`.Range:round-digits].

Gtk.Range.signals.move_slider(range, step)
Signal Name:

move-slider

Flags:

RUN_LAST, ACTION

Parameters:

Virtual function that moves the slider.

Used for keybindings.

Gtk.Range.signals.value_changed(range)
Signal Name:

value-changed

Flags:

RUN_LAST

Parameters:

range (Gtk.Range) – The object which received the signal

Emitted when the range value changes.

Property Details

Gtk.Range.props.adjustment
Name:

adjustment

Type:

Gtk.Adjustment

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY

The adjustment that is controlled by the range.

Gtk.Range.props.fill_level
Name:

fill-level

Type:

float

Default Value:

1.7976931348623157e+308

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The fill level (e.g. prebuffering of a network stream).

Gtk.Range.props.inverted
Name:

inverted

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If True, the direction in which the slider moves is inverted.

Gtk.Range.props.restrict_to_fill_level
Name:

restrict-to-fill-level

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Controls whether slider movement is restricted to an upper boundary set by the fill level.

Gtk.Range.props.round_digits
Name:

round-digits

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The number of digits to round the value to when it changes.

See [signal`Gtk`.Range::change-value].

Gtk.Range.props.show_fill_level
Name:

show-fill-level

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Controls whether fill level indicator graphics are displayed on the trough.