mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-06 13:30:41 +02:00
number slider: make step_size follow the passed type
step_size will be an integer if value is an integer
This commit is contained in:
parent
a3be2e35eb
commit
db3f0977c2
@ -18,7 +18,7 @@ class NumberSlider(DataService):
|
|||||||
The minimum value of the slider. Defaults to 0.
|
The minimum value of the slider. Defaults to 0.
|
||||||
max (float, optional):
|
max (float, optional):
|
||||||
The maximum value of the slider. Defaults to 100.
|
The maximum value of the slider. Defaults to 100.
|
||||||
step_size (float, optional):
|
step_size (float | int, optional):
|
||||||
The increment/decrement step size of the slider. Defaults to 1.0.
|
The increment/decrement step size of the slider. Defaults to 1.0.
|
||||||
type (Literal["int"] | Literal["float"], optional):
|
type (Literal["int"] | Literal["float"], optional):
|
||||||
The type of the slider value. Determines if the value is an integer or float.
|
The type of the slider value. Determines if the value is an integer or float.
|
||||||
@ -42,7 +42,7 @@ class NumberSlider(DataService):
|
|||||||
value: float | int = 0,
|
value: float | int = 0,
|
||||||
min: float = 0.0,
|
min: float = 0.0,
|
||||||
max: float = 100.0,
|
max: float = 100.0,
|
||||||
step_size: float = 1.0,
|
step_size: float | int = 1.0,
|
||||||
type: Literal["int"] | Literal["float"] = "float",
|
type: Literal["int"] | Literal["float"] = "float",
|
||||||
) -> None:
|
) -> None:
|
||||||
self.min = min
|
self.min = min
|
||||||
@ -59,7 +59,7 @@ class NumberSlider(DataService):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def __setattr__(self, name: str, value: Any) -> None:
|
def __setattr__(self, name: str, value: Any) -> None:
|
||||||
if name == "value":
|
if name in ["value", "step_size"]:
|
||||||
value = int(value) if self._type == "int" else float(value)
|
value = int(value) if self._type == "int" else float(value)
|
||||||
elif not name.startswith("_"):
|
elif not name.startswith("_"):
|
||||||
value = float(value)
|
value = float(value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user