Gtk.Range

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Buildable->Gtk.Widget Gtk.Range Gtk.Range Gtk.Orientable->Gtk.Range Gtk.Widget->Gtk.Range

Subclasses:Gtk.Scale, Gtk.Scrollbar

Virtual Methods

Inherited:Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)
  do_adjust_bounds (new_value)
  do_change_value (scroll, new_value)
  do_get_range_border (border_)
  do_get_range_size_request (orientation, minimum, natural)
  do_move_slider (scroll)
  do_value_changed ()

Properties

Inherited:Gtk.Widget (39), Gtk.Orientable (1)
Name Type Flags Short Description
adjustment Gtk.Adjustment r/w/c The Gtk.Adjustment that contains the current value of this range object
fill-level float r/w/en The fill level.
inverted bool r/w/en Invert direction slider moves to increase range value
lower-stepper-sensitivity Gtk.SensitivityType d/r/w/en The sensitivity policy for the stepper that points to the adjustment’s lower side deprecated
restrict-to-fill-level bool r/w/en Whether to restrict the upper boundary to the fill level.
round-digits int r/w/en The number of digits to round the value to.
show-fill-level bool r/w/en Whether to display a fill level indicator graphics on trough.
upper-stepper-sensitivity Gtk.SensitivityType d/r/w/en The sensitivity policy for the stepper that points to the adjustment’s upper side deprecated

Style Properties

Inherited:Gtk.Widget (17)
Name Type Default Flags Short Description
arrow-displacement-x int 0 d/r How far in the x direction to move the arrow when the button is depressed deprecated
arrow-displacement-y int 0 d/r How far in the y direction to move the arrow when the button is depressed deprecated
arrow-scaling float 0.5 d/r Arrow scaling with regard to scroll button size deprecated
slider-width int 14 d/r Width of scrollbar or scale thumb deprecated
stepper-size int 14 d/r Length of step buttons at ends deprecated
stepper-spacing int 0 d/r Spacing between step buttons and thumb deprecated
trough-border int 1 d/r Spacing between thumb/steppers and outer trough bevel deprecated
trough-under-steppers bool True d/r Whether to draw trough for full length of range or exclude the steppers and spacing deprecated

Signals

Inherited:Gtk.Widget (69), 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 The Gtk.Range ::change-value signal is 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 (69), GObject.Object (1)
Name Type Access Description
widget Gtk.Widget r  

Class Details

class Gtk.Range(**kwargs)
Bases:Gtk.Widget, Gtk.Orientable
Abstract:Yes
Structure:Gtk.RangeClass

Gtk.Range is the common base class for widgets which visualize an adjustment, e.g Gtk.Scale or Gtk.Scrollbar.

Apart from signals for monitoring the parameters of the adjustment, Gtk.Range provides properties and methods for influencing the sensitivity of the “steppers”. It also provides properties and methods for setting a “fill level” on range widgets. See Gtk.Range.set_fill_level().

get_adjustment()[source]
Returns:a Gtk.Adjustment
Return type:Gtk.Adjustment

Get the Gtk.Adjustment which is the “model” object for Gtk.Range. See Gtk.Range.set_adjustment() for details. The return value does not have a reference added, so should not be unreferenced.

get_fill_level()[source]
Returns:The current fill level
Return type:float

Gets the current position of the fill level indicator.

New in version 2.12.

get_flippable()[source]
Returns:True if the range is flippable
Return type:bool

Gets the value set by Gtk.Range.set_flippable().

New in version 2.18.

get_inverted()[source]
Returns:True if the range is inverted
Return type:bool

Gets the value set by Gtk.Range.set_inverted().

get_lower_stepper_sensitivity()[source]
Returns:The lower stepper’s sensitivity policy.
Return type:Gtk.SensitivityType

Gets the sensitivity policy for the stepper that points to the ‘lower’ end of the Gtk.Range’s adjustment.

New in version 2.10.

get_min_slider_size()[source]
Returns:The minimum size of the range’s slider.
Return type:int

This function is useful mainly for Gtk.Range subclasses.

See Gtk.Range.set_min_slider_size().

New in version 2.20.

Deprecated since version 3.20: Use the min-height/min-width CSS properties on the slider node.

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 and its steppers, in widget->window coordinates.

This function is useful mainly for Gtk.Range subclasses.

New in version 2.20.

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.

New in version 2.12.

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 Gtk.Range ::change-value.

New in version 2.24.

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.

New in version 2.12.

get_slider_range()[source]
Returns:
slider_start:return location for the slider’s start, or None
slider_end:return location for the slider’s end, or None
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 Gtk.Range subclasses.

New in version 2.20.

get_slider_size_fixed()[source]
Returns:whether the range’s slider has a fixed size.
Return type:bool

This function is useful mainly for Gtk.Range subclasses.

See Gtk.Range.set_slider_size_fixed().

New in version 2.20.

get_upper_stepper_sensitivity()[source]
Returns:The upper stepper’s sensitivity policy.
Return type:Gtk.SensitivityType

Gets the sensitivity policy for the stepper that points to the ‘upper’ end of the Gtk.Range’s adjustment.

New in version 2.10.

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 Gtk.Adjustment

Sets the adjustment to be used as the “model” object for this range widget. 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 Gtk.Scale and nonzero for Gtk.Scrollbar, 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 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 controller by Gtk.Range.set_restrict_to_fill_level() and is by default enabled.

New in version 2.12.

set_flippable(flippable)[source]
Parameters:flippable (bool) – True to make the range flippable

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

See Gtk.Widget.get_direction().

New in version 2.18.

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 Gtk.Scrollbar arrows or moves Gtk.Scale 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

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_lower_stepper_sensitivity(sensitivity)[source]
Parameters:sensitivity (Gtk.SensitivityType) – the lower stepper’s sensitivity policy.

Sets the sensitivity policy for the stepper that points to the ‘lower’ end of the Gtk.Range’s adjustment.

New in version 2.10.

set_min_slider_size(min_size)[source]
Parameters:min_size (int) – The slider’s minimum size

Sets the minimum size of the range’s slider.

This function is useful mainly for Gtk.Range subclasses.

New in version 2.20.

Deprecated since version 3.20: Use the min-height/min-width CSS properties on the slider node.

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

Sets the allowable values in the Gtk.Range, and clamps the range value 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 Gtk.Range.set_fill_level() for a general description of the fill level concept.

New in version 2.12.

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 Gtk.Range ::change-value.

New in version 2.24.

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 Gtk.Range.set_fill_level() for a general description of the fill level concept.

New in version 2.12.

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 Gtk.Range subclasses.

New in version 2.20.

set_upper_stepper_sensitivity(sensitivity)[source]
Parameters:sensitivity (Gtk.SensitivityType) – the upper stepper’s sensitivity policy.

Sets the sensitivity policy for the stepper that points to the ‘upper’ end of the Gtk.Range’s adjustment.

New in version 2.10.

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 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_get_range_size_request(orientation, minimum, natural) virtual
Parameters:
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

The Gtk.Range ::change-value signal is 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 Gtk.Range ::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 Gtk.Range :round-digits.

New in version 2.6.

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

The Gtk.Adjustment that contains the current value of this range object

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). See Gtk.Range.set_fill_level().

New in version 2.12.

Gtk.Range.props.inverted
Name:inverted
Type:bool
Default Value:False
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

Invert direction slider moves to increase range value

Gtk.Range.props.lower_stepper_sensitivity
Name:lower-stepper-sensitivity
Type:Gtk.SensitivityType
Default Value:Gtk.SensitivityType.AUTO
Flags:DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The sensitivity policy for the stepper that points to the adjustment’s lower side

Deprecated since version ???.

Gtk.Range.props.restrict_to_fill_level
Name:restrict-to-fill-level
Type:bool
Default Value:True
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

The restrict-to-fill-level property controls whether slider movement is restricted to an upper boundary set by the fill level. See Gtk.Range.set_restrict_to_fill_level().

New in version 2.12.

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, or -1. See Gtk.Range ::change-value.

New in version 2.24.

Gtk.Range.props.show_fill_level
Name:show-fill-level
Type:bool
Default Value:False
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

The show-fill-level property controls whether fill level indicator graphics are displayed on the trough. See Gtk.Range.set_show_fill_level().

New in version 2.12.

Gtk.Range.props.upper_stepper_sensitivity
Name:upper-stepper-sensitivity
Type:Gtk.SensitivityType
Default Value:Gtk.SensitivityType.AUTO
Flags:DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The sensitivity policy for the stepper that points to the adjustment’s upper side

Deprecated since version ???.