Skip to content

Gtk.Adjustment

class — extends GObject.InitiallyUnowned

A model for a numeric value.

The GtkAdjustment has an associated lower and upper bound. It also contains step and page increments, and a page size.

Adjustments are used within several GTK widgets, including SpinButton, Viewport, Scrollbar and Scale.

The GtkAdjustment object does not update the value itself. Instead it is left up to the owner of the GtkAdjustment to control the value.

Constructors

new

@classmethod
def new(cls, value: float, lower: float, upper: float, step_increment: float, page_increment: float, page_size: float) -> Adjustment

Creates a new GtkAdjustment.

Parameters:

  • value — the initial value
  • lower — the minimum value
  • upper — the maximum value
  • step_increment — the step increment
  • page_increment — the page increment
  • page_size — the page size

Methods

clamp_page

def clamp_page(self, lower: float, upper: float) -> None

Updates the value of the adjustment to ensure that the given range is contained in the current page.

The current page goes from value to value + page-size. If the range is larger than the page size, then only the start of it will be in the current page.

A Adjustment.value-changed signal will be emitted if the value is changed.

Parameters:

  • lower — the lower value
  • upper — the upper value

configure

def configure(self, value: float, lower: float, upper: float, step_increment: float, page_increment: float, page_size: float) -> None

Sets all properties of the adjustment at once.

Use this function to avoid multiple emissions of the Adjustment.changed signal. See Adjustment.set_lower for an alternative way of compressing multiple emissions of Adjustment.changed into one.

Parameters:

  • value — the new value
  • lower — the new minimum value
  • upper — the new maximum value
  • step_increment — the new step increment
  • page_increment — the new page increment
  • page_size — the new page size

get_lower

def get_lower(self) -> float

Retrieves the minimum value of the adjustment.

get_minimum_increment

def get_minimum_increment(self) -> float

Gets the smaller of step increment and page increment.

get_page_increment

def get_page_increment(self) -> float

Retrieves the page increment of the adjustment.

get_page_size

def get_page_size(self) -> float

Retrieves the page size of the adjustment.

get_step_increment

def get_step_increment(self) -> float

Retrieves the step increment of the adjustment.

get_upper

def get_upper(self) -> float

Retrieves the maximum value of the adjustment.

get_value

def get_value(self) -> float

Gets the current value of the adjustment.

set_lower

def set_lower(self, lower: float) -> None

Sets the minimum value of the adjustment.

When setting multiple adjustment properties via their individual setters, multiple Adjustment.changed signals will be emitted. However, since the emission of the Adjustment.changed signal is tied to the emission of the ::notify signals of the changed properties, it’s possible to compress the Adjustment.changed signals into one by calling GObject.Object.freeze_notify and GObject.Object.thaw_notify around the calls to the individual setters.

Alternatively, using a single g_object_set() for all the properties to change, or using Adjustment.configure has the same effect.

Parameters:

  • lower — the new minimum value

set_page_increment

def set_page_increment(self, page_increment: float) -> None

Sets the page increment of the adjustment.

See Adjustment.set_lower about how to compress multiple emissions of the Adjustment.changed signal when setting multiple adjustment properties.

Parameters:

  • page_increment — the new page increment

set_page_size

def set_page_size(self, page_size: float) -> None

Sets the page size of the adjustment.

See Adjustment.set_lower about how to compress multiple emissions of the Adjustment.changed signal when setting multiple adjustment properties.

Parameters:

  • page_size — the new page size

set_step_increment

def set_step_increment(self, step_increment: float) -> None

Sets the step increment of the adjustment.

See Adjustment.set_lower about how to compress multiple emissions of the Adjustment.changed signal when setting multiple adjustment properties.

Parameters:

  • step_increment — the new step increment

set_upper

def set_upper(self, upper: float) -> None

Sets the maximum value of the adjustment.

Note that values will be restricted by upper - page-size if the page-size property is nonzero.

See Adjustment.set_lower about how to compress multiple emissions of the Adjustment.changed signal when setting multiple adjustment properties.

Parameters:

  • upper — the new maximum value

set_value

def set_value(self, value: float) -> None

Sets the GtkAdjustment value.

The value is clamped to lie between Adjustment.lower and Adjustment.upper.

Note that for adjustments which are used in a GtkScrollbar, the effective range of allowed values goes from Adjustment.lower to Adjustment.upper - Adjustment.page-size.

Parameters:

  • value — the new value

Virtual methods

do_changed

def do_changed(self) -> None

do_value_changed

def do_value_changed(self) -> None

Properties

lower

lower: float  # read/write

The minimum value of the adjustment.

page_increment

page_increment: float  # read/write

The page increment of the adjustment.

page_size

page_size: float  # read/write

The page size of the adjustment.

Note that the page-size is irrelevant and should be set to zero if the adjustment is used for a simple scalar value, e.g. in a GtkSpinButton.

step_increment

step_increment: float  # read/write

The step increment of the adjustment.

upper

upper: float  # read/write

The maximum value of the adjustment.

Note that values will be restricted by upper - page-size if the page-size property is nonzero.

value

value: float  # read/write

The value of the adjustment.

Signals

changed

def on_changed(self) -> None: ...

Emitted when one or more of the GtkAdjustment properties have been changed.

Note that the Adjustment.value property is covered by the Adjustment.value-changed signal.

value-changed

def on_value_changed(self) -> None: ...

Emitted when the value has been changed.