Slider

class lib.cli.actions.Slider(*args, min_max: tuple[int, int] | tuple[float, float] | None = None, rounding: int | None = None, **kwargs)

Bases: Action

Adds support for a slider in the GUI.

The standard argparse.Action is extended with the additional parameters listed below. The default value must be supplied and the type must be either int or float. nargs are explicitly disallowed.

Parameters:
  • min_max (tuple) – The (min, max) values that the slider’s range should be set to. The values should be a pair of float or int data types, depending on the data type of the slider. NB: These min/max values are not enforced, they are purely for setting the slider range. Values outside of this range can still be explicitly passed in from the cli.

  • rounding (int) – If the underlying data type for the option is a float then this value is the number of decimal places to round the slider values to. If the underlying data type for the option is an int then this is the step interval between each value for the slider.

Examples

For integer values:

>>> argument_list = []
>>> argument_list.append(dict(
>>>        opts=("-f", "--foobar"),
>>>        action=Slider,
>>>        min_max=(0, 10)
>>>        rounding=1
>>>        type=int,
>>>        default=5))

For floating point values:

>>> argument_list = []
>>> argument_list.append(dict(
>>>        opts=("-f", "--foobar"),
>>>        action=Slider,
>>>        min_max=(0.00, 1.00)
>>>        rounding=2
>>>        type=float,
>>>        default=5.00))

Methods Summary

__call__(parser, namespace, values[, ...])

Call self as a function.

format_usage()

Methods Documentation

__call__(parser, namespace, values, option_string=None) None

Call self as a function.

Return type:

None

format_usage()
__call__(parser, namespace, values, option_string=None) None

Call self as a function.

Return type:

None