Gtk.Adjustment
Gtk.Adjustment — A representation of an adjustable bounded value
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Adjustment
Functions:
- new
(value:float, lower:float, upper:float, step_increment:float, page_increment:float, page_size:float) -> Gtk.Adjustment
- get_value
(self) -> float
- set_value
(self, value:float)
- clamp_page
(self, lower:float, upper:float)
- changed
(self)
- value_changed
(self)
- configure
(self, value:float, lower:float, upper:float, step_increment:float, page_increment:float, page_size:float)
- get_lower
(self) -> float
- get_page_increment
(self) -> float
- get_page_size
(self) -> float
- get_step_increment
(self) -> float
- get_minimum_increment
(self) -> float
- get_upper
(self) -> float
- set_lower
(self, lower:float)
- set_page_increment
(self, page_increment:float)
- set_page_size
(self, page_size:float)
- set_step_increment
(self, step_increment:float)
- set_upper
(self, upper:float)
Signals:
- “changed”
(adjustment, user_data)
- “value-changed”
(adjustment, user_data)
Description:
The Gtk.Adjustment
object represents a value which has an associated lower and upper bound, together with step and page increments, and a page size.
It is used within several GTK+ widgets, including Gtk.SpinButton, Gtk.Viewport, and Gtk.Range (which is a base class for Gtk.Scrollbar and Gtk.Scale).
The Gtk.Adjustment
object does not update the value itself. Instead it is left up to the owner of the Gtk.Adjustment
to control the value.
- Example of Gtk.Scale:
value = random.randint(0, 100)
adjustment = Gtk.Adjustment(value, 0, 100, 1, 10, 0)
self.scale = Gtk.Scale(orientation=Gtk.Orientation.VERTICAL, adjustment=adjustment)
Example of Gtk.Scrollbar:
vadjustment = layout.get_vadjustment() hadjustment = layout.get_hadjustment() vscrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.VERTICAL, adjustment=vadjustment) grid.attach(vscrollbar, 1, 0, 1, 1) hscrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.HORIZONTAL, adjustment=hadjustment) grid.attach(hscrollbar, 0, 1, 1, 1)
Function Details:
new()
new (value:float, lower:float, upper:float, step_increment:float, page_increment:float, page_size:float) -> Gtk.Adjustment
Creates a new Gtk.Adjustment
.
- Returns: a new Gtk.Adjustment
get_value()
get_value (self) -> float
Gets the current value of the adjustment.See Gtk.Adjustment:set_value()
.
- Returns: The current value of the adjustment
set_value()
set_value (self, value:float)
Sets the Gtk.Adjustment
value. The value is clamped to lie between“lower” and “upper”.
Note that for adjustments which are used in a Gtk.Scrollbar
, theeffective range of allowed values goes from “lower” to“upper” - “page-size”.
clamp_page()
clamp_page (self, lower:float, upper:float)
Updates the “value” property to ensure that the rangebetween lower
and upper
is in the current page (i.e. between“value” and “value” + “page-size”).If the range is larger than the page size, then only the start of it willbe in the current page.
A “value-changed” signal will be emitted if the value is changed.
changed()
changed (self)
Gtk.Adjustment:changed
has been deprecated since version 3.18 and should not be used in newly-written code.
GTK+ emits “changed” itself whenever any of the properties (other than value) change
Emits a “changed” signal from the Gtk.Adjustment
.This is typically called by the owner of the Gtk.Adjustment
after it haschanged any of the Gtk.Adjustment
properties other than the value.
value_changed()
value_changed (self)
Gtk.Adjustment:value_changed
has been deprecated since version 3.18 and should not be used in newly-written code.
GTK+ emits “value-changed” itself whenever the value changes
Emits a “value-changed” signal from the Gtk.Adjustment
.This is typically called by the owner of the Gtk.Adjustment
after it haschanged the “value” property.
configure()
configure (self, value:float, lower:float, upper:float, step_increment:float, page_increment:float, page_size:float)
Sets all properties of the adjustment at once.
Use this function to avoid multiple emissions of the“changed” signal. See Gtk.Adjustment:set_lower()
for an alternative way of compressing multiple emissions of“changed” into one.
- Since: 2.14
get_lower()
get_lower (self) -> float
Retrieves the minimum value of the adjustment.
Returns: The current minimum value of the adjustment
Since: 2.14
get_page_increment()
get_page_increment (self) -> float
Retrieves the page increment of the adjustment.
Returns: The current page increment of the adjustment
Since: 2.14
get_page_size()
get_page_size (self) -> float
Retrieves the page size of the adjustment.
Returns: The current page size of the adjustment
Since: 2.14
get_step_increment()
get_step_increment (self) -> float
Retrieves the step increment of the adjustment.
Returns: The current step increment of the adjustment.
Since: 2.14
get_minimum_increment()
get_minimum_increment (self) -> float
Gets the smaller of step increment and page increment.
Returns: the minimum increment of
adjustment
Since: 3.2
get_upper()
get_upper (self) -> float
Retrieves the maximum value of the adjustment.
Returns: The current maximum value of the adjustment
Since: 2.14
set_lower()
set_lower (self, lower:float)
Sets the minimum value of the adjustment.
When setting multiple adjustment properties via their individualsetters, multiple “changed” signals will be emitted.However, since the emission of the “changed” signalis tied to the emission of the “notify” signals of the changedproperties, it’s possible to compress the “changed”signals into one by calling g_object_freeze_notify()
andg_object_thaw_notify()
around the calls to the individual setters.
Alternatively, using a single g_object_set()
for all the propertiesto change, or using Gtk.Adjustment:configure()
has the same effectof compressing “changed” emissions.
- Since: 2.14
set_page_increment()
set_page_increment (self, page_increment:float)
Sets the page increment of the adjustment.
See Gtk.Adjustment:set_lower()
about how to compress multipleemissions of the “changed” signal when settingmultiple adjustment properties.
- Since: 2.14
set_page_size()
set_page_size (self, page_size:float)
Sets the page size of the adjustment.
See Gtk.Adjustment:set_lower()
about how to compress multipleemissions of the Gtk.Adjustment::changed
signal when settingmultiple adjustment properties.
- Since: 2.14
set_step_increment()
set_step_increment (self, step_increment:float)
Sets the step increment of the adjustment.
See Gtk.Adjustment:set_lower()
about how to compress multipleemissions of the “changed” signal when settingmultiple adjustment properties.
- Since: 2.14
set_upper()
set_upper (self, upper:float)
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 Gtk.Adjustment:set_lower()
about how to compress multipleemissions of the “changed” signal when settingmultiple adjustment properties.
- Since: 2.14