Slider¶
macOS |
GTK+ |
Windows |
iOS |
Android |
Django |
---|---|---|---|---|---|
Usage¶
Reference¶
- class toga.widgets.slider.Slider(id=None, style=None, default=None, range=None, tick_count=None, on_change=None, on_slide=None, on_press=None, on_release=None, enabled=True, factory=None)¶
Slider widget, displays a range of values
- Parameters
id – An identifier for this widget.
style (
Style
) –default (float) – Default value of the slider
range (
tuple
) – Min and max values of the slider in this form (min, max).tick_count (
int
) – How many ticks in range. if None, slider is continuous.on_change (
callable
) – The handler to invoke when the slider value changes.on_press (
callable
) – The handler to invoke when the slider has been pressed.on_release (
callable
) – The handler to invoke when the slider has been released.enabled (bool) – Whether user interaction is possible or not.
factory (
module
) – A python module that is capable to return a implementation of this class with the same name. (optional & normally not needed).
- MIN_WIDTH = 100¶
- add(*children)¶
Add nodes as children of this one. If a node already has a different parent, it will be moved over. This does nothing if a node already is a child of this node.
- Parameters
children – Nodes to add as children of this node.
- Raises
ValueError – If this node is a leaf, and cannot have children.
- property app¶
The App to which this widget belongs. On setting the app we also iterate over all children of this widget and set them to the same app.
- Returns
The
toga.App
to which this widget belongs.- Raises
ValueError – If the widget is already associated with another app.
- property can_have_children¶
Determine if the node can have children.
This does not resolve whether there actually are any children; it only confirms whether children are theoretically allowed.
- property children¶
The children of this node. This always returns a list, even if the node is a leaf and cannot have children.
- Returns
A list of the children for this widget.
- property enabled¶
- focus()¶
- property id¶
The node identifier. This id can be used to target styling directives
- Returns
The widgets identifier as a
str
.
- insert(index, child)¶
Insert a node as a child of this one. If the node already has a different parent, it will be moved over. This does nothing if the node already is a child of this node.
- Parameters
index – Position of child node.
child – A node to insert as a child of this node.
- Raises
ValueError – If this node is a leaf, and cannot have children.
- property max¶
- property min¶
- property on_change¶
The function for when the value of the slider is changed
- Returns
The
callable
that is executed when the value changes.
- property on_press¶
The function for when the user click the slider before sliding it
- Returns
The
callable
that is executed when the slider is clicked.
- property on_release¶
The function for when the user release the slider after sliding it
- Returns
The
callable
that is executed when the slider is released.
- property on_slide¶
The function for when the value of the slider is changed
DEPRECATED: renamed as on_change
- Returns
The
callable
that is executed on slide.
- property parent¶
The parent of this node.
- Returns
The parent of this node. Returns None if this node is the root node.
- property range¶
Range composed of min and max slider value.
- Returns
Returns the range in a
tuple
like this (min, max)
- refresh()¶
Refresh the layout and appearance of the tree this node is contained in.
- refresh_sublayouts()¶
- remove(*children)¶
Remove child nodes of this node. This does nothing if a given node is not a child of this node.
- Parameters
children – Child nodes to remove.
- Raises
ValueError – If this node is a leaf, and cannot have children.
- property root¶
The root of the tree containing this node.
- Returns
The root node. Returns self if this node is the root node.
- property tick_count¶
- property tick_step¶
- property tick_value¶
The value of the slider, measured in ticks.
If tick count is not None, a value between 1 and tick count. Otherwise, None.
- property value¶
Current slider value.
- Returns
The current slider value as a
float
.- Raises
ValueError – If the new value is not in the range of min and max.
- property window¶
The Window to which this widget belongs. On setting the window, we automatically update all children of this widget to belong to the same window.
- Returns
The
toga.Window
to which the widget belongs.