Rate Slider#
- squap.add_rate_slider(
- name,
- init_value=1.0,
- change_rate=10.0,
- absolute=False,
- time_var=None,
- custom_func=None,
- var_name=None,
- print_value=False,
- row=None,
Adds a
rate sliderto the main input widget, or to allinput tablesif there are more.- Parameters:
name (str) – The name in front of the rate slider.
init_value (float) – The initial value of the rate slider.
change_rate (float) – Change rate to the value of the variable per second. How it changes depends on
absolute.absolute (bool) – How the value of the variable is changed. If
absoluteisTrue,changeratemultiplied by the slider position (which is a value between-1and1will be added every second. If it is set toFalse, the variable will be multiplied bychangeratemultiplied by the slider position every second.time_var (str, optional) – If set to
None(default), actual time will be used. It can also be set to the name of a variable insquap.varas a string. Then that variable will be regarded as time: if it increases by 1, the variable belonging to this box will be changed bychangerate.custom_func (Callable, optional) – the function that changes the created variable. Overrides
absoluteandchange_rate. It must take three arguments:old_value,dtandslider_valueand must return the new value.old_valueis the value of the variable the previous time the function was run,dtis the change in time since then (takestime_varinto account).slider_valueis a value between-1and1, dependent on the slider position.var_name (str, optional) – The name of the created variable. If
var_nameis not provided, the variable will be namedname.print_value (bool) – Whether to print the value of the slider when it changes. Defaults to
False.row (int, optional) – Row to which the rate slider is added. Defaults to first empty row.
- Returns:
The created
rate_slider widget(s).- Return type:
RateSlider or list of RateSlider
- class squap.widgets.InputTable.RateSlider#
- RateSlider.bind(func)#
Bind function
functo this box, meaning that when the value of the box is changed, the function is called.- Parameters:
func (callable) – function to bind to this box.
- RateSlider.unbind(func)#
Unbind function. Is used internally when removing a box.
- Parameters:
func (callable) – function to unbind from this box.
- RateSlider.set_value(value)#
Set the value of the box and var.var_name to
value. Note that for a slider, the new slider position will be the closest possible position tovalue, and the new value of var.var_name will be the value corresponding to the new slider position.
- RateSlider.value()#
Return the current value of var.var_name
- RateSlider.change_params(**kwargs)#
Changes the parameters of the rate_slider. Only keyword arguments are accepted, and takes all arguments that
squap.add_rate_slider()accepts, exceptinit_valueandrow.
- RateSlider.print_val()#
Print the current value of the box. Used for the
print_valuekeyword argument.
- RateSlider.remove()#
Remove this box.