Another attempt at parameters in Python, built to satisfy requirements of Stytra:
- Automatic GUI building
- Global parameter tree structure
- Parametrized functions
- Saving and restoring
The basic parameter object. The value can be of any python type, although automatic GUI generation is supported for some:
int
float
lists
str
range (a tuple of floats)
folder
Class where some parameters are attributes. Their values are acessible with the dot syntax, and the parameter objects themselves thorugh the params attribute:
class MyParametrized(Parametrized):
def __init__(self):
super().__init__()
self.x = Param(1.0, (0.0, 2.0))
>>> o = MyParametrized()
>>> o.x
1.0
>>> o.params.x.limits
(0.0, 2.0)
Currently, automatic GUI generation is supported for PyQt5 and for ipywidget support.
Arguments of functions can be parametrized by annotaning their arguments using the Python 3 function annotation syntax. For example:
def func(x : Param(1.0)):
print(x)
one can easily make parametrized objects out of it
p = Parametrized(params=func)