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,
)[source]#

Adds a rate slider to the main input widget, or to all input tables if 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 absolute is True, changerate multiplied by the slider position (which is a value between -1 and 1 will be added every second. If it is set to False, the variable will be multiplied by changerate multiplied 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 in squap.var as a string. Then that variable will be regarded as time: if it increases by 1, the variable belonging to this box will be changed by changerate.

  • custom_func (Callable, optional) – the function that changes the created variable. Overrides absolute and change_rate. It must take three arguments: old_value, dt and slider_value and must return the new value. old_value is the value of the variable the previous time the function was run, dt is the change in time since then (takes time_var into account). slider_value is a value between -1 and 1, dependent on the slider position.

  • var_name (str, optional) – The name of the created variable. If var_name is not provided, the variable will be named name.

  • 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 func to 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 to value, 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, except init_value and row.

RateSlider.print_val()#

Print the current value of the box. Used for the print_value keyword argument.

RateSlider.remove()#

Remove this box.