ex4nicegui 0.6.5__py3-none-any.whl → 0.6.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ex4nicegui/__init__.py +3 -2
- ex4nicegui/bi/elements/ui_echarts.py +2 -5
- ex4nicegui/libs/gsap/.DS_Store +0 -0
- ex4nicegui/libs/gsap/gsap.mjs +6 -0
- ex4nicegui/reactive/EChartsComponent/ECharts.js +69 -86
- ex4nicegui/reactive/EChartsComponent/ECharts.py +20 -103
- ex4nicegui/reactive/EChartsComponent/events.py +26 -0
- ex4nicegui/reactive/EChartsComponent/types.py +51 -0
- ex4nicegui/reactive/EChartsComponent/utils.py +44 -0
- ex4nicegui/reactive/deferredTask.py +29 -0
- ex4nicegui/reactive/officials/aggrid.py +3 -3
- ex4nicegui/reactive/officials/base.py +10 -0
- ex4nicegui/reactive/officials/button.py +4 -4
- ex4nicegui/reactive/officials/checkbox.py +3 -3
- ex4nicegui/reactive/officials/circular_progress.py +3 -3
- ex4nicegui/reactive/officials/color_picker.py +4 -4
- ex4nicegui/reactive/officials/column.py +3 -2
- ex4nicegui/reactive/officials/date.py +4 -9
- ex4nicegui/reactive/officials/echarts.py +39 -34
- ex4nicegui/reactive/officials/expansion.py +3 -2
- ex4nicegui/reactive/officials/icon.py +4 -4
- ex4nicegui/reactive/officials/image.py +3 -3
- ex4nicegui/reactive/officials/input.py +4 -4
- ex4nicegui/reactive/officials/knob.py +3 -3
- ex4nicegui/reactive/officials/label.py +4 -3
- ex4nicegui/reactive/officials/linear_progress.py +4 -4
- ex4nicegui/reactive/officials/number.py +24 -5
- ex4nicegui/reactive/officials/radio.py +4 -4
- ex4nicegui/reactive/officials/select.py +4 -4
- ex4nicegui/reactive/officials/slider.py +3 -3
- ex4nicegui/reactive/officials/switch.py +3 -3
- ex4nicegui/reactive/officials/tab_panels.py +14 -2
- ex4nicegui/reactive/officials/table.py +5 -4
- ex4nicegui/reactive/officials/tabs.py +3 -2
- ex4nicegui/reactive/officials/textarea.py +3 -3
- ex4nicegui/reactive/q_pagination.py +3 -2
- ex4nicegui/utils/clientScope.py +14 -6
- {ex4nicegui-0.6.5.dist-info → ex4nicegui-0.6.7.dist-info}/METADATA +1245 -1099
- {ex4nicegui-0.6.5.dist-info → ex4nicegui-0.6.7.dist-info}/RECORD +65 -60
- {ex4nicegui-0.6.5.dist-info → ex4nicegui-0.6.7.dist-info}/WHEEL +1 -2
- ex4nicegui-0.6.5.dist-info/top_level.txt +0 -1
- {ex4nicegui-0.6.5.dist-info → ex4nicegui-0.6.7.dist-info}/LICENSE +0 -0
|
@@ -5,7 +5,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
5
5
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
6
6
|
|
|
7
7
|
from ex4nicegui.utils.signals import (
|
|
8
|
-
|
|
8
|
+
TGetterOrReadonlyRef,
|
|
9
9
|
_TMaybeRef as TMaybeRef,
|
|
10
10
|
to_value,
|
|
11
11
|
)
|
|
@@ -50,13 +50,13 @@ class CircularProgressBindableUi(
|
|
|
50
50
|
def value(self):
|
|
51
51
|
return self.element.value
|
|
52
52
|
|
|
53
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
53
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
54
54
|
if prop == "value":
|
|
55
55
|
return self.bind_value(ref_ui)
|
|
56
56
|
|
|
57
57
|
return super().bind_prop(prop, ref_ui)
|
|
58
58
|
|
|
59
|
-
def bind_value(self, ref_ui:
|
|
59
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
|
|
60
60
|
@ui_effect
|
|
61
61
|
def _():
|
|
62
62
|
self.element.set_value(to_value(ref_ui))
|
|
@@ -8,7 +8,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
8
8
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
9
9
|
|
|
10
10
|
from ex4nicegui.utils.signals import (
|
|
11
|
-
|
|
11
|
+
TGetterOrReadonlyRef,
|
|
12
12
|
Ref,
|
|
13
13
|
_TMaybeRef as TMaybeRef,
|
|
14
14
|
is_setter_ref,
|
|
@@ -69,20 +69,20 @@ class ColorPickerBindableUi(BindableUi[ui.color_picker]):
|
|
|
69
69
|
def value(self):
|
|
70
70
|
return self.element.value
|
|
71
71
|
|
|
72
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
72
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
73
73
|
if prop == "value":
|
|
74
74
|
return self.bind_value(ref_ui)
|
|
75
75
|
|
|
76
76
|
return super().bind_prop(prop, ref_ui)
|
|
77
77
|
|
|
78
|
-
def bind_color(self, ref_ui:
|
|
78
|
+
def bind_color(self, ref_ui: TGetterOrReadonlyRef[str]):
|
|
79
79
|
@ui_effect
|
|
80
80
|
def _():
|
|
81
81
|
self.element.set_color(to_value(ref_ui))
|
|
82
82
|
|
|
83
83
|
return self
|
|
84
84
|
|
|
85
|
-
def bind_value(self, ref_ui:
|
|
85
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef[bool]):
|
|
86
86
|
@ui_effect
|
|
87
87
|
def _():
|
|
88
88
|
self.element.set_value(to_value(ref_ui))
|
|
@@ -3,6 +3,7 @@ from typing import (
|
|
|
3
3
|
)
|
|
4
4
|
from ex4nicegui.reactive.utils import ParameterClassifier
|
|
5
5
|
from ex4nicegui.utils.signals import (
|
|
6
|
+
TGetterOrReadonlyRef,
|
|
6
7
|
_TMaybeRef as TMaybeRef,
|
|
7
8
|
)
|
|
8
9
|
from nicegui import ui
|
|
@@ -19,13 +20,13 @@ class ColumnBindableUi(BindableUi[ui.column]):
|
|
|
19
20
|
for key, value in pc.get_bindings().items():
|
|
20
21
|
self.bind_prop(key, value) # type: ignore
|
|
21
22
|
|
|
22
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
23
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
23
24
|
if prop == "wrap":
|
|
24
25
|
return self.bind_wrap(ref_ui)
|
|
25
26
|
|
|
26
27
|
return super().bind_prop(prop, ref_ui)
|
|
27
28
|
|
|
28
|
-
def bind_wrap(self, ref_ui:
|
|
29
|
+
def bind_wrap(self, ref_ui: TGetterOrReadonlyRef):
|
|
29
30
|
self.bind_classes({"wrap": ref_ui})
|
|
30
31
|
|
|
31
32
|
def __enter__(self):
|
|
@@ -4,7 +4,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
4
4
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
5
5
|
|
|
6
6
|
from ex4nicegui.utils.signals import (
|
|
7
|
-
|
|
7
|
+
TGetterOrReadonlyRef,
|
|
8
8
|
_TMaybeRef as TMaybeRef,
|
|
9
9
|
to_value,
|
|
10
10
|
)
|
|
@@ -45,13 +45,8 @@ class DateBindableUi(BindableUi[ui.date]):
|
|
|
45
45
|
pc = ParameterClassifier(
|
|
46
46
|
locals(),
|
|
47
47
|
maybeRefs=[
|
|
48
|
-
"label",
|
|
49
48
|
"value",
|
|
50
|
-
"
|
|
51
|
-
"password",
|
|
52
|
-
"password_toggle_button",
|
|
53
|
-
"autocomplete",
|
|
54
|
-
"validation",
|
|
49
|
+
"mask",
|
|
55
50
|
],
|
|
56
51
|
v_model=("value", "on_change"),
|
|
57
52
|
events=["on_change"],
|
|
@@ -68,13 +63,13 @@ class DateBindableUi(BindableUi[ui.date]):
|
|
|
68
63
|
def value(self):
|
|
69
64
|
return self.element.value
|
|
70
65
|
|
|
71
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
66
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
72
67
|
if prop == "value":
|
|
73
68
|
return self.bind_value(ref_ui)
|
|
74
69
|
|
|
75
70
|
return super().bind_prop(prop, ref_ui)
|
|
76
71
|
|
|
77
|
-
def bind_value(self, ref_ui:
|
|
72
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef[bool]):
|
|
78
73
|
@ui_effect
|
|
79
74
|
def _():
|
|
80
75
|
self.element.set_value(to_value(ref_ui))
|
|
@@ -1,37 +1,23 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Any, Callable, Dict, List, Union, cast, Optional
|
|
3
|
-
from typing_extensions import Literal
|
|
2
|
+
from typing import Any, Callable, Dict, List, Union, cast, Optional, Literal
|
|
4
3
|
from ex4nicegui.reactive.utils import ParameterClassifier
|
|
5
|
-
from ex4nicegui.utils.signals import on
|
|
6
|
-
|
|
7
4
|
from ex4nicegui.utils.signals import (
|
|
8
|
-
|
|
5
|
+
TGetterOrReadonlyRef,
|
|
9
6
|
is_ref,
|
|
10
7
|
ref_computed,
|
|
11
8
|
_TMaybeRef as TMaybeRef,
|
|
12
9
|
to_value,
|
|
13
10
|
to_raw,
|
|
11
|
+
on,
|
|
14
12
|
)
|
|
15
13
|
from .base import BindableUi
|
|
16
|
-
from ex4nicegui.reactive.EChartsComponent.ECharts import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
14
|
+
from ex4nicegui.reactive.EChartsComponent.ECharts import echarts
|
|
15
|
+
from ex4nicegui.reactive.EChartsComponent.types import _T_event_name
|
|
16
|
+
from ex4nicegui.reactive.EChartsComponent.events import EChartsMouseEventArguments
|
|
20
17
|
|
|
21
18
|
from nicegui.awaitable_response import AwaitableResponse
|
|
22
19
|
from nicegui import ui, app
|
|
23
|
-
|
|
24
|
-
_TEventName = Literal[
|
|
25
|
-
"click",
|
|
26
|
-
"dblclick",
|
|
27
|
-
"mousedown",
|
|
28
|
-
"mousemove",
|
|
29
|
-
"mouseup",
|
|
30
|
-
"mouseover",
|
|
31
|
-
"mouseout",
|
|
32
|
-
"globalout",
|
|
33
|
-
"contextmenu",
|
|
34
|
-
]
|
|
20
|
+
import orjson as json
|
|
35
21
|
|
|
36
22
|
|
|
37
23
|
class EChartsBindableUi(BindableUi[echarts]):
|
|
@@ -50,6 +36,7 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
50
36
|
value_kws = pc.get_values_kws()
|
|
51
37
|
|
|
52
38
|
element = echarts(**value_kws).classes("grow self-stretch h-[16rem]")
|
|
39
|
+
|
|
53
40
|
super().__init__(element) # type: ignore
|
|
54
41
|
|
|
55
42
|
self.__update_setting = None
|
|
@@ -60,7 +47,14 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
60
47
|
self.bind_prop(key, value) # type: ignore
|
|
61
48
|
|
|
62
49
|
@classmethod
|
|
63
|
-
def register_map(
|
|
50
|
+
def register_map(
|
|
51
|
+
cls,
|
|
52
|
+
map_name: str,
|
|
53
|
+
src: Union[str, Path],
|
|
54
|
+
*,
|
|
55
|
+
type: Literal["geoJSON", "svg"] = "geoJSON",
|
|
56
|
+
special_areas: Optional[Dict[str, Any]] = None,
|
|
57
|
+
):
|
|
64
58
|
"""Registers available maps. This can only be used after including geo component or chart series of map.
|
|
65
59
|
|
|
66
60
|
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#rxuiechartsregister_map
|
|
@@ -69,6 +63,8 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
69
63
|
Args:
|
|
70
64
|
map_name (str): Map name, referring to map value set in geo component or map.
|
|
71
65
|
src (Union[str, Path]): Map data. If str, it should be a network address. If path, it should be a valid file.
|
|
66
|
+
type (Literal["geoJSON", "svg"], optional): Map data type. Defaults to "geoJSON".
|
|
67
|
+
special_areas (Optional[Dict[str, Any]], optional): Special areas. Defaults to None.
|
|
72
68
|
"""
|
|
73
69
|
if isinstance(src, Path):
|
|
74
70
|
src = app.add_static_file(local_file=src)
|
|
@@ -77,18 +73,26 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
77
73
|
|
|
78
74
|
ui.add_body_html(
|
|
79
75
|
rf"""
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
<script>
|
|
77
|
+
(function () {{
|
|
78
|
+
if (typeof window.ex4ngEchartsMapTasks === "undefined") {{
|
|
79
|
+
window.ex4ngEchartsMapTasks = new Map();
|
|
80
|
+
}}
|
|
81
|
+
|
|
82
|
+
const value = {{
|
|
83
|
+
src: '{src}',
|
|
84
|
+
type: '{type}',
|
|
85
|
+
specialAreas: {json.dumps(special_areas).decode('utf-8')}
|
|
86
|
+
}}
|
|
87
|
+
|
|
88
|
+
window.ex4ngEchartsMapTasks.set('{map_name}', value);
|
|
89
|
+
}})()
|
|
90
|
+
</script>
|
|
89
91
|
"""
|
|
90
92
|
)
|
|
91
93
|
|
|
94
|
+
return cls
|
|
95
|
+
|
|
92
96
|
@classmethod
|
|
93
97
|
def from_pyecharts(cls, chart: TMaybeRef):
|
|
94
98
|
if is_ref(chart):
|
|
@@ -130,13 +134,13 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
130
134
|
code = code.read_text("utf8")
|
|
131
135
|
return cls(code=code)
|
|
132
136
|
|
|
133
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
137
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
134
138
|
if prop == "options":
|
|
135
139
|
return self.bind_options(ref_ui)
|
|
136
140
|
|
|
137
141
|
return super().bind_prop(prop, ref_ui)
|
|
138
142
|
|
|
139
|
-
def bind_options(self, ref_ui:
|
|
143
|
+
def bind_options(self, ref_ui: TGetterOrReadonlyRef[Dict]):
|
|
140
144
|
@on(ref_ui)
|
|
141
145
|
def _():
|
|
142
146
|
ele = self.element
|
|
@@ -147,7 +151,7 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
147
151
|
|
|
148
152
|
def on(
|
|
149
153
|
self,
|
|
150
|
-
event_name:
|
|
154
|
+
event_name: _T_event_name,
|
|
151
155
|
handler: Callable[..., Any],
|
|
152
156
|
query: Optional[Union[str, Dict]] = None,
|
|
153
157
|
):
|
|
@@ -224,6 +228,7 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
224
228
|
---
|
|
225
229
|
"""
|
|
226
230
|
self.element.echarts_on(event_name, handler, query)
|
|
231
|
+
return self
|
|
227
232
|
|
|
228
233
|
def run_chart_method(
|
|
229
234
|
self, name: str, *args, timeout: float = 1, check_interval: float = 0.01
|
|
@@ -3,6 +3,7 @@ from nicegui import ui
|
|
|
3
3
|
from ex4nicegui.reactive.utils import ParameterClassifier
|
|
4
4
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
5
5
|
from ex4nicegui.utils.signals import (
|
|
6
|
+
TGetterOrReadonlyRef,
|
|
6
7
|
_TMaybeRef as TMaybeRef,
|
|
7
8
|
to_value,
|
|
8
9
|
)
|
|
@@ -45,13 +46,13 @@ class ExpansionBindableUi(BindableUi[ui.expansion]):
|
|
|
45
46
|
def value(self):
|
|
46
47
|
return self.element.value
|
|
47
48
|
|
|
48
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
49
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
49
50
|
if prop == "value":
|
|
50
51
|
return self.bind_value(ref_ui)
|
|
51
52
|
|
|
52
53
|
return super().bind_prop(prop, ref_ui)
|
|
53
54
|
|
|
54
|
-
def bind_value(self, ref_ui:
|
|
55
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
55
56
|
@ui_effect
|
|
56
57
|
def _():
|
|
57
58
|
self.element.set_value(to_value(ref_ui))
|
|
@@ -6,7 +6,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
6
6
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
7
7
|
|
|
8
8
|
from ex4nicegui.utils.signals import (
|
|
9
|
-
|
|
9
|
+
TGetterOrReadonlyRef,
|
|
10
10
|
_TMaybeRef as TMaybeRef,
|
|
11
11
|
to_value,
|
|
12
12
|
)
|
|
@@ -35,7 +35,7 @@ class IconBindableUi(BindableUi[ui.icon]):
|
|
|
35
35
|
for key, value in pc.get_bindings().items():
|
|
36
36
|
self.bind_prop(key, value) # type: ignore
|
|
37
37
|
|
|
38
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
38
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
39
39
|
if prop == "name":
|
|
40
40
|
return self.bind_name(ref_ui)
|
|
41
41
|
|
|
@@ -44,10 +44,10 @@ class IconBindableUi(BindableUi[ui.icon]):
|
|
|
44
44
|
|
|
45
45
|
return super().bind_prop(prop, ref_ui)
|
|
46
46
|
|
|
47
|
-
def bind_color(self, ref_ui:
|
|
47
|
+
def bind_color(self, ref_ui: TGetterOrReadonlyRef):
|
|
48
48
|
return _bind_color(self, ref_ui)
|
|
49
49
|
|
|
50
|
-
def bind_name(self, ref_ui:
|
|
50
|
+
def bind_name(self, ref_ui: TGetterOrReadonlyRef):
|
|
51
51
|
@ui_effect
|
|
52
52
|
def _():
|
|
53
53
|
ele = cast(TextColorElement, self.element)
|
|
@@ -6,7 +6,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
6
6
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
7
7
|
|
|
8
8
|
from ex4nicegui.utils.signals import (
|
|
9
|
-
|
|
9
|
+
TGetterOrReadonlyRef,
|
|
10
10
|
_TMaybeRef as TMaybeRef,
|
|
11
11
|
to_value,
|
|
12
12
|
)
|
|
@@ -27,13 +27,13 @@ class ImageBindableUi(BindableUi[ui.image]):
|
|
|
27
27
|
for key, value in pc.get_bindings().items():
|
|
28
28
|
self.bind_prop(key, value) # type: ignore
|
|
29
29
|
|
|
30
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
30
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
31
31
|
if prop == "source":
|
|
32
32
|
return self.bind_source(ref_ui)
|
|
33
33
|
|
|
34
34
|
return super().bind_prop(prop, ref_ui)
|
|
35
35
|
|
|
36
|
-
def bind_source(self, ref_ui:
|
|
36
|
+
def bind_source(self, ref_ui: TGetterOrReadonlyRef[Union[str, Path]]):
|
|
37
37
|
@ui_effect
|
|
38
38
|
def _():
|
|
39
39
|
self.element.set_source(to_value(ref_ui))
|
|
@@ -3,7 +3,7 @@ from ex4nicegui.utils.apiEffect import ui_effect
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
from ex4nicegui.utils.signals import (
|
|
6
|
-
|
|
6
|
+
TGetterOrReadonlyRef,
|
|
7
7
|
Ref,
|
|
8
8
|
_TMaybeRef as TMaybeRef,
|
|
9
9
|
effect,
|
|
@@ -53,7 +53,7 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
53
53
|
for key, value in pc.get_bindings().items():
|
|
54
54
|
self.bind_prop(key, value) # type: ignore
|
|
55
55
|
|
|
56
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
56
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
57
57
|
if prop == "value":
|
|
58
58
|
return self.bind_value(ref_ui)
|
|
59
59
|
if prop == "password":
|
|
@@ -61,7 +61,7 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
61
61
|
|
|
62
62
|
return super().bind_prop(prop, ref_ui)
|
|
63
63
|
|
|
64
|
-
def bind_value(self, ref_ui:
|
|
64
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef[str]):
|
|
65
65
|
@ui_effect
|
|
66
66
|
def _():
|
|
67
67
|
self.element.set_value(to_value(ref_ui))
|
|
@@ -69,7 +69,7 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
69
69
|
|
|
70
70
|
return self
|
|
71
71
|
|
|
72
|
-
def bind_password(self, ref_ui:
|
|
72
|
+
def bind_password(self, ref_ui: TGetterOrReadonlyRef[bool]):
|
|
73
73
|
@ui_effect
|
|
74
74
|
def _():
|
|
75
75
|
self.element._props["type"] = "password" if to_value(ref_ui) else "text"
|
|
@@ -7,9 +7,9 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
7
7
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
8
8
|
|
|
9
9
|
from ex4nicegui.utils.signals import (
|
|
10
|
-
ReadonlyRef,
|
|
11
10
|
_TMaybeRef as TMaybeRef,
|
|
12
11
|
to_value,
|
|
12
|
+
TGetterOrReadonlyRef,
|
|
13
13
|
)
|
|
14
14
|
from nicegui import ui
|
|
15
15
|
from .base import BindableUi, DisableableMixin
|
|
@@ -61,13 +61,13 @@ class KnobBindableUi(
|
|
|
61
61
|
def value(self):
|
|
62
62
|
return self.element.value
|
|
63
63
|
|
|
64
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
64
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
65
65
|
if prop == "value":
|
|
66
66
|
return self.bind_value(ref_ui)
|
|
67
67
|
|
|
68
68
|
return super().bind_prop(prop, ref_ui)
|
|
69
69
|
|
|
70
|
-
def bind_value(self, ref_ui:
|
|
70
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
|
|
71
71
|
@ui_effect
|
|
72
72
|
def _():
|
|
73
73
|
self.element.set_value(to_value(ref_ui))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
from ex4nicegui.reactive.utils import ParameterClassifier
|
|
3
3
|
from ex4nicegui.utils.signals import (
|
|
4
|
+
TGetterOrReadonlyRef,
|
|
4
5
|
to_value,
|
|
5
6
|
_TMaybeRef as TMaybeRef,
|
|
6
7
|
)
|
|
@@ -25,7 +26,7 @@ class LabelBindableUi(BindableUi[ui.label]):
|
|
|
25
26
|
def text(self):
|
|
26
27
|
return self.element.text
|
|
27
28
|
|
|
28
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
29
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
29
30
|
if prop == "text":
|
|
30
31
|
return self.bind_text(ref_ui)
|
|
31
32
|
|
|
@@ -34,7 +35,7 @@ class LabelBindableUi(BindableUi[ui.label]):
|
|
|
34
35
|
|
|
35
36
|
return super().bind_prop(prop, ref_ui)
|
|
36
37
|
|
|
37
|
-
def bind_color(self, ref_ui:
|
|
38
|
+
def bind_color(self, ref_ui: TGetterOrReadonlyRef):
|
|
38
39
|
@self._ui_effect
|
|
39
40
|
def _():
|
|
40
41
|
ele = self.element
|
|
@@ -42,7 +43,7 @@ class LabelBindableUi(BindableUi[ui.label]):
|
|
|
42
43
|
ele._style["color"] = color
|
|
43
44
|
ele.update()
|
|
44
45
|
|
|
45
|
-
def bind_text(self, ref_ui:
|
|
46
|
+
def bind_text(self, ref_ui: TGetterOrReadonlyRef):
|
|
46
47
|
@self._ui_effect
|
|
47
48
|
def _():
|
|
48
49
|
self.element.set_text(str(to_value(ref_ui)))
|
|
@@ -5,7 +5,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
5
5
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
6
6
|
|
|
7
7
|
from ex4nicegui.utils.signals import (
|
|
8
|
-
|
|
8
|
+
TGetterOrReadonlyRef,
|
|
9
9
|
_TMaybeRef as TMaybeRef,
|
|
10
10
|
to_value,
|
|
11
11
|
)
|
|
@@ -47,7 +47,7 @@ class LinearProgressBindableUi(BindableUi[ui.linear_progress]):
|
|
|
47
47
|
def value(self):
|
|
48
48
|
return self.element.value
|
|
49
49
|
|
|
50
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
50
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
51
51
|
if prop == "value":
|
|
52
52
|
return self.bind_value(ref_ui)
|
|
53
53
|
|
|
@@ -56,10 +56,10 @@ class LinearProgressBindableUi(BindableUi[ui.linear_progress]):
|
|
|
56
56
|
|
|
57
57
|
return super().bind_prop(prop, ref_ui)
|
|
58
58
|
|
|
59
|
-
def bind_color(self, ref_ui:
|
|
59
|
+
def bind_color(self, ref_ui: TGetterOrReadonlyRef):
|
|
60
60
|
return _bind_color(self, ref_ui)
|
|
61
61
|
|
|
62
|
-
def bind_value(self, ref_ui:
|
|
62
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
63
63
|
@ui_effect
|
|
64
64
|
def _():
|
|
65
65
|
self.element.set_value(to_value(ref_ui))
|
|
@@ -4,14 +4,16 @@ from typing import (
|
|
|
4
4
|
Optional,
|
|
5
5
|
TypeVar,
|
|
6
6
|
Dict,
|
|
7
|
+
Union,
|
|
7
8
|
)
|
|
8
9
|
from ex4nicegui.reactive.utils import ParameterClassifier
|
|
9
10
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
10
11
|
|
|
11
12
|
from ex4nicegui.utils.signals import (
|
|
12
|
-
|
|
13
|
+
TGetterOrReadonlyRef,
|
|
13
14
|
_TMaybeRef as TMaybeRef,
|
|
14
15
|
to_value,
|
|
16
|
+
on,
|
|
15
17
|
)
|
|
16
18
|
from nicegui import ui
|
|
17
19
|
from .base import BindableUi
|
|
@@ -19,15 +21,20 @@ from .base import BindableUi
|
|
|
19
21
|
T = TypeVar("T")
|
|
20
22
|
|
|
21
23
|
|
|
24
|
+
def _default_vmodel_args_getter(e):
|
|
25
|
+
return e.sender.value
|
|
26
|
+
|
|
27
|
+
|
|
22
28
|
class NumberBindableUi(BindableUi[ui.number]):
|
|
23
29
|
def __init__(
|
|
24
30
|
self,
|
|
25
31
|
label: Optional[TMaybeRef[str]] = None,
|
|
26
32
|
*,
|
|
27
33
|
placeholder: Optional[TMaybeRef[str]] = None,
|
|
28
|
-
value: Optional[TMaybeRef[float]] = None,
|
|
34
|
+
value: Optional[Union[TMaybeRef[float], TMaybeRef[int]]] = None,
|
|
29
35
|
min: Optional[TMaybeRef[float]] = None,
|
|
30
36
|
max: Optional[TMaybeRef[float]] = None,
|
|
37
|
+
precision: Optional[TMaybeRef[int]] = None,
|
|
31
38
|
step: Optional[TMaybeRef[float]] = None,
|
|
32
39
|
prefix: Optional[TMaybeRef[str]] = None,
|
|
33
40
|
suffix: Optional[TMaybeRef[str]] = None,
|
|
@@ -43,6 +50,7 @@ class NumberBindableUi(BindableUi[ui.number]):
|
|
|
43
50
|
"value",
|
|
44
51
|
"min",
|
|
45
52
|
"max",
|
|
53
|
+
"precision",
|
|
46
54
|
"step",
|
|
47
55
|
"prefix",
|
|
48
56
|
"suffix",
|
|
@@ -51,10 +59,10 @@ class NumberBindableUi(BindableUi[ui.number]):
|
|
|
51
59
|
],
|
|
52
60
|
v_model=("value", "on_change"),
|
|
53
61
|
events=["on_change"],
|
|
62
|
+
v_model_arg_getter=_default_vmodel_args_getter,
|
|
54
63
|
)
|
|
55
64
|
|
|
56
65
|
value_kws = pc.get_values_kws()
|
|
57
|
-
|
|
58
66
|
element = ui.number(**value_kws)
|
|
59
67
|
super().__init__(element) # type: ignore
|
|
60
68
|
|
|
@@ -65,15 +73,26 @@ class NumberBindableUi(BindableUi[ui.number]):
|
|
|
65
73
|
def value(self):
|
|
66
74
|
return self.element.value
|
|
67
75
|
|
|
68
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
76
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
69
77
|
if prop == "value":
|
|
70
78
|
return self.bind_value(ref_ui)
|
|
71
79
|
|
|
80
|
+
if prop == "precision":
|
|
81
|
+
return self._bind_precision(ref_ui)
|
|
82
|
+
|
|
72
83
|
return super().bind_prop(prop, ref_ui)
|
|
73
84
|
|
|
74
|
-
def bind_value(self, ref_ui:
|
|
85
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
|
|
75
86
|
@ui_effect
|
|
76
87
|
def _():
|
|
77
88
|
self.element.set_value(to_value(ref_ui))
|
|
78
89
|
|
|
79
90
|
return self
|
|
91
|
+
|
|
92
|
+
def _bind_precision(self, ref_ui: TGetterOrReadonlyRef[int]):
|
|
93
|
+
@on(ref_ui, onchanges=True)
|
|
94
|
+
def _():
|
|
95
|
+
self.element.precision = to_value(ref_ui)
|
|
96
|
+
self.element.sanitize()
|
|
97
|
+
|
|
98
|
+
return self
|
|
@@ -12,7 +12,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
12
12
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
13
13
|
|
|
14
14
|
from ex4nicegui.utils.signals import (
|
|
15
|
-
|
|
15
|
+
TGetterOrReadonlyRef,
|
|
16
16
|
_TMaybeRef as TMaybeRef,
|
|
17
17
|
to_value,
|
|
18
18
|
)
|
|
@@ -53,7 +53,7 @@ class RadioBindableUi(BindableUi[ui.radio]):
|
|
|
53
53
|
def value(self):
|
|
54
54
|
return self.element.value
|
|
55
55
|
|
|
56
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
56
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
57
57
|
if prop == "value":
|
|
58
58
|
return self.bind_value(ref_ui)
|
|
59
59
|
|
|
@@ -62,14 +62,14 @@ class RadioBindableUi(BindableUi[ui.radio]):
|
|
|
62
62
|
|
|
63
63
|
return super().bind_prop(prop, ref_ui)
|
|
64
64
|
|
|
65
|
-
def bind_options(self, ref_ui:
|
|
65
|
+
def bind_options(self, ref_ui: TGetterOrReadonlyRef):
|
|
66
66
|
@ui_effect
|
|
67
67
|
def _():
|
|
68
68
|
self.element.set_options(to_value(ref_ui))
|
|
69
69
|
|
|
70
70
|
return self
|
|
71
71
|
|
|
72
|
-
def bind_value(self, ref_ui:
|
|
72
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
73
73
|
@ui_effect
|
|
74
74
|
def _():
|
|
75
75
|
cast(ValueElement, self.element).set_value(to_value(ref_ui))
|
|
@@ -12,7 +12,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
12
12
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
13
13
|
|
|
14
14
|
from ex4nicegui.utils.signals import (
|
|
15
|
-
|
|
15
|
+
TGetterOrReadonlyRef,
|
|
16
16
|
_TMaybeRef as TMaybeRef,
|
|
17
17
|
to_value,
|
|
18
18
|
)
|
|
@@ -75,7 +75,7 @@ class SelectBindableUi(BindableUi[ui.select]):
|
|
|
75
75
|
def value(self):
|
|
76
76
|
return self.element.value
|
|
77
77
|
|
|
78
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
78
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
79
79
|
if prop == "value":
|
|
80
80
|
return self.bind_value(ref_ui)
|
|
81
81
|
|
|
@@ -84,14 +84,14 @@ class SelectBindableUi(BindableUi[ui.select]):
|
|
|
84
84
|
|
|
85
85
|
return super().bind_prop(prop, ref_ui)
|
|
86
86
|
|
|
87
|
-
def bind_options(self, ref_ui:
|
|
87
|
+
def bind_options(self, ref_ui: TGetterOrReadonlyRef):
|
|
88
88
|
@ui_effect()
|
|
89
89
|
def _():
|
|
90
90
|
self.element.set_options(to_value(ref_ui))
|
|
91
91
|
|
|
92
92
|
return self
|
|
93
93
|
|
|
94
|
-
def bind_value(self, ref_ui:
|
|
94
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
95
95
|
@ui_effect()
|
|
96
96
|
def _():
|
|
97
97
|
cast(ValueElement, self.element).set_value(to_value(ref_ui) or None)
|
|
@@ -9,7 +9,7 @@ from ex4nicegui.reactive.utils import ParameterClassifier
|
|
|
9
9
|
from ex4nicegui.utils.apiEffect import ui_effect
|
|
10
10
|
|
|
11
11
|
from ex4nicegui.utils.signals import (
|
|
12
|
-
|
|
12
|
+
TGetterOrReadonlyRef,
|
|
13
13
|
Ref,
|
|
14
14
|
_TMaybeRef as TMaybeRef,
|
|
15
15
|
is_setter_ref,
|
|
@@ -60,13 +60,13 @@ class SliderBindableUi(
|
|
|
60
60
|
def value(self):
|
|
61
61
|
return self.element.value
|
|
62
62
|
|
|
63
|
-
def bind_prop(self, prop: str, ref_ui:
|
|
63
|
+
def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
|
|
64
64
|
if prop == "value":
|
|
65
65
|
return self.bind_value(ref_ui)
|
|
66
66
|
|
|
67
67
|
return super().bind_prop(prop, ref_ui)
|
|
68
68
|
|
|
69
|
-
def bind_value(self, ref_ui:
|
|
69
|
+
def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
|
|
70
70
|
@ui_effect
|
|
71
71
|
def _():
|
|
72
72
|
self.element.set_value(to_value(ref_ui))
|