Spinner¶
Widget description¶
A spinner is a widget which allows the user to increase or decrease numeric values using arrow buttons, or edit values directly, clicking over it and typing the new value.
By default the spinner will not wrap and has a label
of "%.0f"
(just showing the integer value of the double).
A spinner has a label that is formatted with floating
point values and thus accepts a printf-style format string, like
"%1.2f units"
.
It also allows specific values to be replaced by pre-defined labels.
Emitted signals¶
changed
- Whenever the spinner value is changed.delay,changed
- A short time after the value is changed by the user. This will be called only when the user stops dragging for a very short period or when they release their finger/mouse, so it avoids possibly expensive reactions to the value change.spinner,drag,start
- When dragging has started.spinner,drag,stop
- When dragging has stopped.min,reached
- Called when spinner value reached min (since 1.20)max,reached
- Called when spinner value reached max (since 1.20)
Available styles¶
default
: Default stylevertical
: up/down buttons at the right side and text left aligned.
Inheritance diagram¶
- class efl.elementary.Spinner(Object parent, *args, **kwargs)¶
Bases:
efl.elementary.__init__.LayoutClass
This is the class that actually implements the widget.
- Parameters
parent (
efl.evas.Object
) – The parent object**kwargs – All the remaining keyword arguments are interpreted as properties of the instance
- base¶
The base for rounding
Rounding works as follows:
rounded_val = base + (double)(((value - base) / round) * round)
Where rounded_val, value and base are doubles, and round is an integer.
This means that things will be rounded to increments (or decrements) of “round” starting from the value of this property. The default base for rounding is 0.
Example: round = 3, base = 2 Values: …, -2, 0, 2, 5, 8, 11, 14, …
Example: round = 2, base = 5.5 Values: …, -0.5, 1.5, 3.5, 5.5, 7.5, 9.5, 11.5, …
See also
- Type
float
- base_get()¶
- base_set(base)¶
- callback_changed_add(func, *args, **kwargs)¶
Whenever the spinner value is changed.
- callback_changed_del(func)¶
- callback_delay_changed_add(func, *args, **kwargs)¶
A short time after the value is changed by the user. This will be called only when the user stops dragging for a very short period or when they release their finger/mouse, so it avoids possibly expensive reactions to the value change.
- callback_delay_changed_del(func)¶
- callback_drag_start_add(func, *args, **kwargs)¶
When dragging has started.
New in version 1.19.
- callback_drag_start_del(func)¶
- callback_drag_stop_add(func, *args, **kwargs)¶
When dragging has stopped.
New in version 1.19.
- callback_drag_stop_del(func)¶
- callback_max_reached_add(func, *args, **kwargs)¶
When spinner value reached max.
New in version 1.20.
- callback_max_reached_del(func)¶
- callback_min_reached_add(func, *args, **kwargs)¶
When spinner value reached min.
New in version 1.20.
- callback_min_reached_del(func)¶
- editable¶
Whether the spinner can be directly edited by the user or not.
Spinner objects can have edition disabled, in which state they will be changed only by arrows. Useful for contexts where you don’t want your users to interact with it writing the value. Specially when using special values, the user can see real value instead of special label on edition.
It’s enabled by default.
- Type
bool
- editable_get()¶
- editable_set(editable)¶
- interval¶
The interval on time updates for an user mouse button hold on spinner widgets’ arrows.
This interval value is decreased while the user holds the mouse pointer either incrementing or decrementing spinner’s value.
This helps the user to get to a given value distant from the current one easier/faster, as it will start to change quicker and quicker on mouse button holds.
The calculation for the next change interval value, starting from the one set with this call, is the previous interval divided by
1.05
, so it decreases a little bit.The default starting interval value for automatic changes is
0.85
seconds.- Type
float
- interval_get()¶
- interval_set(interval)¶
- label_format¶
The format string of the displayed label.
If set to
None
, the format is set to"%.0f"
. If not it sets the format string for the label text. The label text is provided a floating point value, so the label text can display up to 1 floating point value. Note that this is optional.Use a format string such as
"%1.2f meters"
for example, and it will display values like: “3.14 meters” for a value equal to 3.14159.Default is
"%0.f"
.- Type
unicode
- label_format_get()¶
- label_format_set(label_format)¶
- min_max¶
The minimum and maximum values for the spinner.
If actual value is less than
min
, it will be updated tomin
. If it is bigger thenmax
, will be updated tomax
. Actual value can be get withvalue
.By default, min is equal to 0, and max is equal to 100.
Warning
Maximum must be greater than minimum.
- Type
(float, float)
- min_max_get()¶
- min_max_set(min, max)¶
- round_get()¶
- round_set(rnd)¶
- special_value_add(value, label)¶
Set a special string to display in the place of the numerical value.
It’s useful for cases when a user should select an item that is better indicated by a label than a value. For example, weekdays or months.
E.g.:
sp = Spinner(win) sp.min_max_set(1, 3) sp.special_value_add(1, "January") sp.special_value_add(2, "February") sp.special_value_add(3, "March") sp.show()
- Parameters
value (float) – The value to be replaced.
label (unicode) – The label to be used.
- special_value_del(value)¶
Delete the special string display in the place of the numerical value.
- Parameters
value – The replaced value.
It will remove a previously added special value. After this, the spinner will display the value itself instead of a label.
- See
special_value_add()
for more details.
New in version 1.8.
- special_value_get(value)¶
Get the special string display in the place of the numerical value.
- Parameters
value – The replaced value.
- Returns
The used label.
- See
special_value_add()
for more details.
New in version 1.8.
- step¶
The step used to increment or decrement the spinner value.
This value will be incremented or decremented to the displayed value. It will be incremented while the user keep right or top arrow pressed, and will be decremented while the user keep left or bottom arrow pressed.
The interval to increment / decrement can be set with
interval
.By default step value is equal to 1.
- Type
float
- step_get()¶
- step_set(step)¶
- value¶
The value the spinner displays.
Value will be presented on the label following format specified with
label_format
.Warning
The value must to be between min and max values. This values are set by
min_max
.- Type
float
- value_get()¶
- value_set(value)¶
- wrap¶
Whether the spinner should wrap when it reaches its minimum or maximum value.
Disabled by default. If disabled, when the user tries to increment the value, but displayed value plus step value is bigger than maximum value, the spinner won’t allow it. The same happens when the user tries to decrement it, but the value less step is less than minimum value.
When wrap is enabled, in such situations it will allow these changes, but will get the value that would be less than minimum and subtracts from maximum. Or add the value that would be more than maximum to the minimum.
E.g.:
min value = 10
max value = 50
step value = 20
displayed value = 20
When the user decrement value (using left or bottom arrow), it will display
40
, because max - (min - (displayed - step)) is50 - (10 - (20 - 20)) = 40
.- Type
bool
- wrap_get()¶
- wrap_set(wrap)¶