Slider#

squap.add_slider(
name,
init_value=1.0,
min_value=0.0,
max_value=10.0,
n_ticks=51,
tick_interval=None,
only_ints=False,
logscale=False,
custom_arr=None,
var_name=None,
print_value=False,
row=None,
)[source]#

Adds a slider to the main input widget, or to all input tables if there are more.

Parameters:
  • name (str) – The name in front of the slider.

  • init_value (float) – The initial value of the slider. If the provided value is not on the slider, it gets set to the closest value.

  • min_value (float) – The minimum value of the slider.

  • max_value (float) – The maximum value of the slider.

  • n_ticks (int) – The number of ticks on the slider. Defaults to 51.

  • tick_interval (float, optional) – The interval between ticks. If provided, overwrites n_ticks.

  • only_ints (bool) – Whether to use whole numbers as ticks. If set to True, tick_interval is used as spacing between the ticks and n_ticks is ignored. If tick_interval is not specified, it defaults to 1. Rounds tick_interval to an integer and changes the variable to always be an integer. Not allowed in combination with logscale. Defaults to False.

  • logscale (bool) – Whether to use a logarithmic scale. When tick_interval is given it serves as a multiplication factor between a point and the previous point (it is rounded to fit min_value and max_value. Not allowed in combination with only_ints. Defaults to False.

  • custom_arr (iterable, optional) – Array or list of values, where custom_arr[i] will be the value (can be any type) of the slider when it is set to position i. Overwrites all other parameters (except init_value). Defaults to None.

  • 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 slider is added. Defaults to first empty row.

Returns:

The created slider widget(s).

Return type:

Slider or list of Slider

class squap.widgets.InputTable.Slider#
Slider.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.

Slider.unbind(func)#

Unbind function. Is used internally when removing a box.

Parameters:

func (callable) – function to unbind from this box.

Slider.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.

Slider.value()#

Return the current value of var.var_name

Slider.set_index(index)#

Sets the index to index.

Slider.index()#

Returns the current index.

Slider.change_params(**kwargs)#

Changes the parameters of the slider. Only keyword arguments are accepted, and takes all arguments that squap.add_slider() accepts, except init_value and row.

Slider.print_val()#

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

Slider.remove()#

Remove this box.