ex4nicegui 0.6.9__py3-none-any.whl → 0.7.0__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/bi/dataSourceFacade.py +20 -20
- ex4nicegui/bi/index.py +20 -23
- ex4nicegui/reactive/EChartsComponent/ECharts.py +9 -8
- ex4nicegui/reactive/__init__.py +8 -0
- ex4nicegui/reactive/base.py +61 -54
- ex4nicegui/reactive/mixins/backgroundColor.py +5 -5
- ex4nicegui/reactive/mixins/disableable.py +8 -8
- ex4nicegui/reactive/mixins/textColor.py +10 -10
- ex4nicegui/reactive/officials/aggrid.py +5 -5
- ex4nicegui/reactive/officials/button.py +15 -15
- ex4nicegui/reactive/officials/checkbox.py +5 -5
- ex4nicegui/reactive/officials/chip.py +5 -5
- ex4nicegui/reactive/officials/circular_progress.py +6 -6
- ex4nicegui/reactive/officials/color_picker.py +7 -7
- ex4nicegui/reactive/officials/column.py +5 -5
- ex4nicegui/reactive/officials/date.py +5 -5
- ex4nicegui/reactive/officials/dialog.py +49 -0
- ex4nicegui/reactive/officials/echarts.py +49 -51
- ex4nicegui/reactive/officials/expansion.py +5 -5
- ex4nicegui/reactive/officials/icon.py +6 -6
- ex4nicegui/reactive/officials/image.py +5 -5
- ex4nicegui/reactive/officials/input.py +8 -8
- ex4nicegui/reactive/officials/knob.py +6 -6
- ex4nicegui/reactive/officials/label.py +6 -6
- ex4nicegui/reactive/officials/linear_progress.py +6 -6
- ex4nicegui/reactive/officials/number.py +9 -9
- ex4nicegui/reactive/officials/radio.py +8 -8
- ex4nicegui/reactive/officials/row.py +5 -5
- ex4nicegui/reactive/officials/select.py +9 -8
- ex4nicegui/reactive/officials/slider.py +5 -5
- ex4nicegui/reactive/officials/switch.py +5 -5
- ex4nicegui/reactive/officials/tab.py +0 -12
- ex4nicegui/reactive/officials/tab_panels.py +5 -5
- ex4nicegui/reactive/officials/table.py +13 -13
- ex4nicegui/reactive/officials/tabs.py +5 -5
- ex4nicegui/reactive/officials/textarea.py +5 -5
- ex4nicegui/reactive/officials/tooltip.py +40 -0
- ex4nicegui/reactive/q_pagination.py +5 -5
- ex4nicegui/reactive/vfor.js +14 -4
- ex4nicegui/reactive/vfor.py +128 -58
- ex4nicegui/reactive/view_model.py +160 -0
- ex4nicegui/reactive/vmodel.py +42 -12
- ex4nicegui/utils/signals.py +23 -21
- {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.0.dist-info}/METADATA +219 -48
- {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.0.dist-info}/RECORD +47 -44
- {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.0.dist-info}/LICENSE +0 -0
- {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.0.dist-info}/WHEEL +0 -0
|
@@ -68,23 +68,23 @@ class ColorPickerBindableUi(BindableUi[ui.color_picker]):
|
|
|
68
68
|
def value(self):
|
|
69
69
|
return self.element.value
|
|
70
70
|
|
|
71
|
-
def bind_prop(self, prop: str,
|
|
71
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
72
72
|
if prop == "value":
|
|
73
|
-
return self.bind_value(
|
|
73
|
+
return self.bind_value(value)
|
|
74
74
|
|
|
75
|
-
return super().bind_prop(prop,
|
|
75
|
+
return super().bind_prop(prop, value)
|
|
76
76
|
|
|
77
|
-
def bind_color(self,
|
|
77
|
+
def bind_color(self, color: TGetterOrReadonlyRef[str]):
|
|
78
78
|
@self._ui_effect
|
|
79
79
|
def _():
|
|
80
|
-
self.element.set_color(to_value(
|
|
80
|
+
self.element.set_color(to_value(color))
|
|
81
81
|
|
|
82
82
|
return self
|
|
83
83
|
|
|
84
|
-
def bind_value(self,
|
|
84
|
+
def bind_value(self, value: TGetterOrReadonlyRef[bool]):
|
|
85
85
|
@self._ui_effect
|
|
86
86
|
def _():
|
|
87
|
-
self.element.set_value(to_value(
|
|
87
|
+
self.element.set_value(to_value(value))
|
|
88
88
|
|
|
89
89
|
return self
|
|
90
90
|
|
|
@@ -20,14 +20,14 @@ class ColumnBindableUi(BindableUi[ui.column]):
|
|
|
20
20
|
for key, value in pc.get_bindings().items():
|
|
21
21
|
self.bind_prop(key, value) # type: ignore
|
|
22
22
|
|
|
23
|
-
def bind_prop(self, prop: str,
|
|
23
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
24
24
|
if prop == "wrap":
|
|
25
|
-
return self.bind_wrap(
|
|
25
|
+
return self.bind_wrap(value)
|
|
26
26
|
|
|
27
|
-
return super().bind_prop(prop,
|
|
27
|
+
return super().bind_prop(prop, value)
|
|
28
28
|
|
|
29
|
-
def bind_wrap(self,
|
|
30
|
-
self.bind_classes({"wrap":
|
|
29
|
+
def bind_wrap(self, value: TGetterOrReadonlyRef):
|
|
30
|
+
self.bind_classes({"wrap": value})
|
|
31
31
|
|
|
32
32
|
def __enter__(self):
|
|
33
33
|
self.element.__enter__()
|
|
@@ -62,15 +62,15 @@ class DateBindableUi(BindableUi[ui.date]):
|
|
|
62
62
|
def value(self):
|
|
63
63
|
return self.element.value
|
|
64
64
|
|
|
65
|
-
def bind_prop(self, prop: str,
|
|
65
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
66
66
|
if prop == "value":
|
|
67
|
-
return self.bind_value(
|
|
67
|
+
return self.bind_value(value)
|
|
68
68
|
|
|
69
|
-
return super().bind_prop(prop,
|
|
69
|
+
return super().bind_prop(prop, value)
|
|
70
70
|
|
|
71
|
-
def bind_value(self,
|
|
71
|
+
def bind_value(self, value: TGetterOrReadonlyRef[bool]):
|
|
72
72
|
@self._ui_effect
|
|
73
73
|
def _():
|
|
74
|
-
self.element.set_value(to_value(
|
|
74
|
+
self.element.set_value(to_value(value))
|
|
75
75
|
|
|
76
76
|
return self
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
2
|
+
from ex4nicegui.utils.signals import (
|
|
3
|
+
_TMaybeRef as TMaybeRef,
|
|
4
|
+
is_setter_ref,
|
|
5
|
+
to_value,
|
|
6
|
+
TGetterOrReadonlyRef,
|
|
7
|
+
)
|
|
8
|
+
from nicegui import ui
|
|
9
|
+
from .base import BindableUi
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DialogBindableUi(BindableUi[ui.dialog]):
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
*,
|
|
16
|
+
value: TMaybeRef[bool] = False,
|
|
17
|
+
) -> None:
|
|
18
|
+
pc = ParameterClassifier(locals(), maybeRefs=["value"])
|
|
19
|
+
|
|
20
|
+
value_kws = pc.get_values_kws()
|
|
21
|
+
element = ui.dialog(**value_kws)
|
|
22
|
+
super().__init__(element) # type: ignore
|
|
23
|
+
|
|
24
|
+
if is_setter_ref(value):
|
|
25
|
+
|
|
26
|
+
def on_value_change():
|
|
27
|
+
value.value = element.value # type: ignore
|
|
28
|
+
|
|
29
|
+
element.on_value_change(on_value_change)
|
|
30
|
+
|
|
31
|
+
for key, value in pc.get_bindings().items():
|
|
32
|
+
self.bind_prop(key, value) # type: ignore
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def value(self):
|
|
36
|
+
return self.element.value
|
|
37
|
+
|
|
38
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
39
|
+
if prop == "value":
|
|
40
|
+
return self.bind_value(value)
|
|
41
|
+
|
|
42
|
+
return super().bind_prop(prop, value)
|
|
43
|
+
|
|
44
|
+
def bind_value(self, value: TGetterOrReadonlyRef[float]):
|
|
45
|
+
@self._ui_effect
|
|
46
|
+
def _():
|
|
47
|
+
self.element.set_value(to_value(value))
|
|
48
|
+
|
|
49
|
+
return self
|
|
@@ -119,31 +119,30 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
119
119
|
|
|
120
120
|
## Examples
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
```
|
|
122
|
+
.. code-block:: python
|
|
123
|
+
rxui.echarts.from_javascript(
|
|
124
|
+
r'''(myChart) => {
|
|
125
|
+
option = {...};
|
|
126
|
+
myChart.setOption(option);
|
|
127
|
+
}
|
|
128
|
+
''')
|
|
130
129
|
|
|
131
130
|
"""
|
|
132
131
|
if isinstance(code, Path):
|
|
133
132
|
code = code.read_text("utf8")
|
|
134
133
|
return cls(code=code)
|
|
135
134
|
|
|
136
|
-
def bind_prop(self, prop: str,
|
|
135
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
137
136
|
if prop == "options":
|
|
138
|
-
return self.bind_options(
|
|
137
|
+
return self.bind_options(value)
|
|
139
138
|
|
|
140
|
-
return super().bind_prop(prop,
|
|
139
|
+
return super().bind_prop(prop, value)
|
|
141
140
|
|
|
142
|
-
def bind_options(self,
|
|
143
|
-
@self._ui_signal_on(
|
|
141
|
+
def bind_options(self, options: TGetterOrReadonlyRef[Dict]):
|
|
142
|
+
@self._ui_signal_on(options)
|
|
144
143
|
def _():
|
|
145
144
|
ele = self.element
|
|
146
|
-
ele.update_options(to_raw(to_value(
|
|
145
|
+
ele.update_options(to_raw(to_value(options)), self.__update_setting)
|
|
147
146
|
ele.update()
|
|
148
147
|
|
|
149
148
|
return self
|
|
@@ -171,58 +170,57 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
171
170
|
---
|
|
172
171
|
|
|
173
172
|
### click event:
|
|
174
|
-
```python
|
|
175
|
-
bar = rxui.echarts(opts)
|
|
176
173
|
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
.. code-block:: python
|
|
175
|
+
bar = rxui.echarts(opts)
|
|
176
|
+
|
|
177
|
+
def on_click(e):
|
|
178
|
+
ui.notify(f"on_click:{e}")
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
```
|
|
180
|
+
bar.on("click", on_click)
|
|
182
181
|
|
|
183
182
|
---
|
|
184
183
|
|
|
185
184
|
### Use query to trigger callback of the specified component:
|
|
186
185
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
.. code-block:: python
|
|
187
|
+
...
|
|
188
|
+
def on_line_click(e):
|
|
189
|
+
ui.notify(e)
|
|
190
|
+
|
|
191
|
+
bar.on("click", on_line_click,query='series.line')
|
|
191
192
|
|
|
192
|
-
bar.on("click", on_line_click,query='series.line')
|
|
193
|
-
```
|
|
194
193
|
|
|
195
194
|
---
|
|
196
195
|
### only trigger for specified series
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
},
|
|
205
|
-
"series": [
|
|
206
|
-
{
|
|
207
|
-
"name": "first",
|
|
208
|
-
"type": "bar",
|
|
209
|
-
"data": [18203, 23489, 29034, 104970, 131744, 630230],
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
"name": "second",
|
|
213
|
-
"type": "bar",
|
|
214
|
-
"data": [19325, 23438, 31000, 121594, 134141, 681807],
|
|
196
|
+
|
|
197
|
+
.. code-block:: python
|
|
198
|
+
opts = {
|
|
199
|
+
"xAxis": {"type": "value", "boundaryGap": [0, 0.01]},
|
|
200
|
+
"yAxis": {
|
|
201
|
+
"type": "category",
|
|
202
|
+
"data": ["Brazil", "Indonesia", "USA", "India", "China", "World"],
|
|
215
203
|
},
|
|
216
|
-
|
|
217
|
-
|
|
204
|
+
"series": [
|
|
205
|
+
{
|
|
206
|
+
"name": "first",
|
|
207
|
+
"type": "bar",
|
|
208
|
+
"data": [18203, 23489, 29034, 104970, 131744, 630230],
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "second",
|
|
212
|
+
"type": "bar",
|
|
213
|
+
"data": [19325, 23438, 31000, 121594, 134141, 681807],
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
}
|
|
218
217
|
|
|
219
|
-
|
|
218
|
+
bar = rxui.echarts(opts)
|
|
220
219
|
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
def on_first_series_mouseover(e):
|
|
221
|
+
ui.notify(f"on_first_series_mouseover:{e}")
|
|
223
222
|
|
|
224
|
-
|
|
225
|
-
```
|
|
223
|
+
bar.on("mouseover", on_first_series_mouseover, query={"seriesName": "first"})
|
|
226
224
|
|
|
227
225
|
---
|
|
228
226
|
"""
|
|
@@ -45,16 +45,16 @@ class ExpansionBindableUi(BindableUi[ui.expansion]):
|
|
|
45
45
|
def value(self):
|
|
46
46
|
return self.element.value
|
|
47
47
|
|
|
48
|
-
def bind_prop(self, prop: str,
|
|
48
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
49
49
|
if prop == "value":
|
|
50
|
-
return self.bind_value(
|
|
50
|
+
return self.bind_value(value)
|
|
51
51
|
|
|
52
|
-
return super().bind_prop(prop,
|
|
52
|
+
return super().bind_prop(prop, value)
|
|
53
53
|
|
|
54
|
-
def bind_value(self,
|
|
54
|
+
def bind_value(self, value: TGetterOrReadonlyRef):
|
|
55
55
|
@self._ui_effect
|
|
56
56
|
def _():
|
|
57
|
-
self.element.set_value(to_value(
|
|
57
|
+
self.element.set_value(to_value(value))
|
|
58
58
|
|
|
59
59
|
return self
|
|
60
60
|
|
|
@@ -34,20 +34,20 @@ class IconBindableUi(BindableUi[ui.icon], TextColorableMixin):
|
|
|
34
34
|
for key, value in pc.get_bindings().items():
|
|
35
35
|
self.bind_prop(key, value) # type: ignore
|
|
36
36
|
|
|
37
|
-
def bind_prop(self, prop: str,
|
|
37
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
38
38
|
if prop == "name":
|
|
39
|
-
return self.bind_name(
|
|
39
|
+
return self.bind_name(value)
|
|
40
40
|
|
|
41
41
|
if prop == "color":
|
|
42
|
-
return self.bind_color(
|
|
42
|
+
return self.bind_color(value)
|
|
43
43
|
|
|
44
|
-
return super().bind_prop(prop,
|
|
44
|
+
return super().bind_prop(prop, value)
|
|
45
45
|
|
|
46
|
-
def bind_name(self,
|
|
46
|
+
def bind_name(self, name: TGetterOrReadonlyRef):
|
|
47
47
|
@self._ui_effect
|
|
48
48
|
def _():
|
|
49
49
|
ele = cast(TextColorElement, self.element)
|
|
50
|
-
ele._props["name"] = to_value(
|
|
50
|
+
ele._props["name"] = to_value(name)
|
|
51
51
|
ele.update()
|
|
52
52
|
|
|
53
53
|
return self
|
|
@@ -25,13 +25,13 @@ class ImageBindableUi(BindableUi[ui.image]):
|
|
|
25
25
|
for key, value in pc.get_bindings().items():
|
|
26
26
|
self.bind_prop(key, value) # type: ignore
|
|
27
27
|
|
|
28
|
-
def bind_prop(self, prop: str,
|
|
28
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
29
29
|
if prop == "source":
|
|
30
|
-
return self.bind_source(
|
|
30
|
+
return self.bind_source(value)
|
|
31
31
|
|
|
32
|
-
return super().bind_prop(prop,
|
|
32
|
+
return super().bind_prop(prop, value)
|
|
33
33
|
|
|
34
|
-
def bind_source(self,
|
|
34
|
+
def bind_source(self, source: TGetterOrReadonlyRef[Union[str, Path]]):
|
|
35
35
|
@self._ui_effect
|
|
36
36
|
def _():
|
|
37
|
-
self.element.set_source(to_value(
|
|
37
|
+
self.element.set_source(to_value(source))
|
|
@@ -51,26 +51,26 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
51
51
|
for key, value in pc.get_bindings().items():
|
|
52
52
|
self.bind_prop(key, value) # type: ignore
|
|
53
53
|
|
|
54
|
-
def bind_prop(self, prop: str,
|
|
54
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
55
55
|
if prop == "value":
|
|
56
|
-
return self.bind_value(
|
|
56
|
+
return self.bind_value(value)
|
|
57
57
|
if prop == "password":
|
|
58
|
-
return self.bind_password(
|
|
58
|
+
return self.bind_password(value)
|
|
59
59
|
|
|
60
|
-
return super().bind_prop(prop,
|
|
60
|
+
return super().bind_prop(prop, value)
|
|
61
61
|
|
|
62
|
-
def bind_value(self,
|
|
62
|
+
def bind_value(self, value: TGetterOrReadonlyRef[str]):
|
|
63
63
|
@self._ui_effect
|
|
64
64
|
def _():
|
|
65
|
-
self.element.set_value(to_value(
|
|
65
|
+
self.element.set_value(to_value(value))
|
|
66
66
|
self.element.update()
|
|
67
67
|
|
|
68
68
|
return self
|
|
69
69
|
|
|
70
|
-
def bind_password(self,
|
|
70
|
+
def bind_password(self, password: TGetterOrReadonlyRef[bool]):
|
|
71
71
|
@self._ui_effect
|
|
72
72
|
def _():
|
|
73
|
-
self.element._props["type"] = "password" if to_value(
|
|
73
|
+
self.element._props["type"] = "password" if to_value(password) else "text"
|
|
74
74
|
self.element.update()
|
|
75
75
|
|
|
76
76
|
return self
|
|
@@ -61,17 +61,17 @@ class KnobBindableUi(
|
|
|
61
61
|
def value(self):
|
|
62
62
|
return self.element.value
|
|
63
63
|
|
|
64
|
-
def bind_prop(self, prop: str,
|
|
64
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
65
65
|
if prop == "value":
|
|
66
|
-
return self.bind_value(
|
|
66
|
+
return self.bind_value(value)
|
|
67
67
|
if prop == "color":
|
|
68
|
-
return self.bind_color(
|
|
68
|
+
return self.bind_color(value)
|
|
69
69
|
|
|
70
|
-
return super().bind_prop(prop,
|
|
70
|
+
return super().bind_prop(prop, value)
|
|
71
71
|
|
|
72
|
-
def bind_value(self,
|
|
72
|
+
def bind_value(self, value: TGetterOrReadonlyRef[float]):
|
|
73
73
|
@self._ui_effect
|
|
74
74
|
def _():
|
|
75
|
-
self.element.set_value(to_value(
|
|
75
|
+
self.element.set_value(to_value(value))
|
|
76
76
|
|
|
77
77
|
return self
|
|
@@ -27,19 +27,19 @@ class LabelBindableUi(BindableUi[ui.label], HtmlTextColorableMixin):
|
|
|
27
27
|
def text(self):
|
|
28
28
|
return self.element.text
|
|
29
29
|
|
|
30
|
-
def bind_prop(self, prop: str,
|
|
30
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
31
31
|
if prop == "text":
|
|
32
|
-
return self.bind_text(
|
|
32
|
+
return self.bind_text(value)
|
|
33
33
|
|
|
34
34
|
if prop == "color":
|
|
35
|
-
return self.bind_color(
|
|
35
|
+
return self.bind_color(value)
|
|
36
36
|
|
|
37
|
-
return super().bind_prop(prop,
|
|
37
|
+
return super().bind_prop(prop, value)
|
|
38
38
|
|
|
39
|
-
def bind_text(self,
|
|
39
|
+
def bind_text(self, text: TGetterOrReadonlyRef):
|
|
40
40
|
@self._ui_effect
|
|
41
41
|
def _():
|
|
42
|
-
self.element.set_text(str(to_value(
|
|
42
|
+
self.element.set_text(str(to_value(text)))
|
|
43
43
|
self.element.update()
|
|
44
44
|
|
|
45
45
|
return self
|
|
@@ -46,18 +46,18 @@ class LinearProgressBindableUi(BindableUi[ui.linear_progress], TextColorableMixi
|
|
|
46
46
|
def value(self):
|
|
47
47
|
return self.element.value
|
|
48
48
|
|
|
49
|
-
def bind_prop(self, prop: str,
|
|
49
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
50
50
|
if prop == "value":
|
|
51
|
-
return self.bind_value(
|
|
51
|
+
return self.bind_value(value)
|
|
52
52
|
|
|
53
53
|
if prop == "color":
|
|
54
|
-
return self.bind_color(
|
|
54
|
+
return self.bind_color(value)
|
|
55
55
|
|
|
56
|
-
return super().bind_prop(prop,
|
|
56
|
+
return super().bind_prop(prop, value)
|
|
57
57
|
|
|
58
|
-
def bind_value(self,
|
|
58
|
+
def bind_value(self, value: TGetterOrReadonlyRef):
|
|
59
59
|
@self._ui_effect
|
|
60
60
|
def _():
|
|
61
|
-
self.element.set_value(to_value(
|
|
61
|
+
self.element.set_value(to_value(value))
|
|
62
62
|
|
|
63
63
|
return self
|
|
@@ -70,26 +70,26 @@ class NumberBindableUi(BindableUi[ui.number]):
|
|
|
70
70
|
def value(self):
|
|
71
71
|
return self.element.value
|
|
72
72
|
|
|
73
|
-
def bind_prop(self, prop: str,
|
|
73
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
74
74
|
if prop == "value":
|
|
75
|
-
return self.bind_value(
|
|
75
|
+
return self.bind_value(value)
|
|
76
76
|
|
|
77
77
|
if prop == "precision":
|
|
78
|
-
return self._bind_precision(
|
|
78
|
+
return self._bind_precision(value)
|
|
79
79
|
|
|
80
|
-
return super().bind_prop(prop,
|
|
80
|
+
return super().bind_prop(prop, value)
|
|
81
81
|
|
|
82
|
-
def bind_value(self,
|
|
82
|
+
def bind_value(self, value: TGetterOrReadonlyRef[float]):
|
|
83
83
|
@self._ui_effect
|
|
84
84
|
def _():
|
|
85
|
-
self.element.set_value(to_value(
|
|
85
|
+
self.element.set_value(to_value(value))
|
|
86
86
|
|
|
87
87
|
return self
|
|
88
88
|
|
|
89
|
-
def _bind_precision(self,
|
|
90
|
-
@self._ui_signal_on(
|
|
89
|
+
def _bind_precision(self, precision: TGetterOrReadonlyRef[int]):
|
|
90
|
+
@self._ui_signal_on(precision, onchanges=True)
|
|
91
91
|
def _():
|
|
92
|
-
self.element.precision = to_value(
|
|
92
|
+
self.element.precision = to_value(precision)
|
|
93
93
|
self.element.sanitize()
|
|
94
94
|
|
|
95
95
|
return self
|
|
@@ -51,25 +51,25 @@ class RadioBindableUi(BindableUi[ui.radio]):
|
|
|
51
51
|
def value(self):
|
|
52
52
|
return self.element.value
|
|
53
53
|
|
|
54
|
-
def bind_prop(self, prop: str,
|
|
54
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
55
55
|
if prop == "value":
|
|
56
|
-
return self.bind_value(
|
|
56
|
+
return self.bind_value(value)
|
|
57
57
|
|
|
58
58
|
if prop == "options":
|
|
59
|
-
return self.bind_options(
|
|
59
|
+
return self.bind_options(value)
|
|
60
60
|
|
|
61
|
-
return super().bind_prop(prop,
|
|
61
|
+
return super().bind_prop(prop, value)
|
|
62
62
|
|
|
63
|
-
def bind_options(self,
|
|
63
|
+
def bind_options(self, options: TGetterOrReadonlyRef):
|
|
64
64
|
@self._ui_effect
|
|
65
65
|
def _():
|
|
66
|
-
self.element.set_options(to_value(
|
|
66
|
+
self.element.set_options(to_value(options))
|
|
67
67
|
|
|
68
68
|
return self
|
|
69
69
|
|
|
70
|
-
def bind_value(self,
|
|
70
|
+
def bind_value(self, value: TGetterOrReadonlyRef):
|
|
71
71
|
@self._ui_effect
|
|
72
72
|
def _():
|
|
73
|
-
cast(ValueElement, self.element).set_value(to_value(
|
|
73
|
+
cast(ValueElement, self.element).set_value(to_value(value))
|
|
74
74
|
|
|
75
75
|
return self
|
|
@@ -18,14 +18,14 @@ class RowBindableUi(BindableUi[ui.row]):
|
|
|
18
18
|
for key, value in pc.get_bindings().items():
|
|
19
19
|
self.bind_prop(key, value) # type: ignore
|
|
20
20
|
|
|
21
|
-
def bind_prop(self, prop: str,
|
|
21
|
+
def bind_prop(self, prop: str, value: TMaybeRef):
|
|
22
22
|
if prop == "wrap":
|
|
23
|
-
return self.bind_wrap(
|
|
23
|
+
return self.bind_wrap(value)
|
|
24
24
|
|
|
25
|
-
return super().bind_prop(prop,
|
|
25
|
+
return super().bind_prop(prop, value)
|
|
26
26
|
|
|
27
|
-
def bind_wrap(self,
|
|
28
|
-
self.bind_classes({"wrap":
|
|
27
|
+
def bind_wrap(self, value: TMaybeRef):
|
|
28
|
+
self.bind_classes({"wrap": value})
|
|
29
29
|
|
|
30
30
|
def __enter__(self):
|
|
31
31
|
self.element.__enter__()
|
|
@@ -13,6 +13,7 @@ from ex4nicegui.utils.signals import (
|
|
|
13
13
|
TGetterOrReadonlyRef,
|
|
14
14
|
_TMaybeRef as TMaybeRef,
|
|
15
15
|
to_value,
|
|
16
|
+
to_raw,
|
|
16
17
|
)
|
|
17
18
|
from nicegui import ui
|
|
18
19
|
from nicegui.elements.mixins.value_element import ValueElement
|
|
@@ -73,25 +74,25 @@ class SelectBindableUi(BindableUi[ui.select]):
|
|
|
73
74
|
def value(self):
|
|
74
75
|
return self.element.value
|
|
75
76
|
|
|
76
|
-
def bind_prop(self, prop: str,
|
|
77
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
77
78
|
if prop == "value":
|
|
78
|
-
return self.bind_value(
|
|
79
|
+
return self.bind_value(value)
|
|
79
80
|
|
|
80
81
|
if prop == "options":
|
|
81
|
-
return self.bind_options(
|
|
82
|
+
return self.bind_options(value)
|
|
82
83
|
|
|
83
|
-
return super().bind_prop(prop,
|
|
84
|
+
return super().bind_prop(prop, value)
|
|
84
85
|
|
|
85
|
-
def bind_options(self,
|
|
86
|
+
def bind_options(self, options: TGetterOrReadonlyRef):
|
|
86
87
|
@self._ui_effect()
|
|
87
88
|
def _():
|
|
88
|
-
self.element.set_options(to_value(
|
|
89
|
+
self.element.set_options(to_value(options))
|
|
89
90
|
|
|
90
91
|
return self
|
|
91
92
|
|
|
92
|
-
def bind_value(self,
|
|
93
|
+
def bind_value(self, value: TGetterOrReadonlyRef):
|
|
93
94
|
@self._ui_effect()
|
|
94
95
|
def _():
|
|
95
|
-
cast(ValueElement, self.element).set_value(to_value(
|
|
96
|
+
cast(ValueElement, self.element).set_value(to_raw(to_value(value)) or None)
|
|
96
97
|
|
|
97
98
|
return self
|
|
@@ -58,16 +58,16 @@ class SliderBindableUi(
|
|
|
58
58
|
def value(self):
|
|
59
59
|
return self.element.value
|
|
60
60
|
|
|
61
|
-
def bind_prop(self, prop: str,
|
|
61
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
62
62
|
if prop == "value":
|
|
63
|
-
return self.bind_value(
|
|
63
|
+
return self.bind_value(value)
|
|
64
64
|
|
|
65
|
-
return super().bind_prop(prop,
|
|
65
|
+
return super().bind_prop(prop, value)
|
|
66
66
|
|
|
67
|
-
def bind_value(self,
|
|
67
|
+
def bind_value(self, value: TGetterOrReadonlyRef[float]):
|
|
68
68
|
@self._ui_effect
|
|
69
69
|
def _():
|
|
70
|
-
self.element.set_value(to_value(
|
|
70
|
+
self.element.set_value(to_value(value))
|
|
71
71
|
self.element.update()
|
|
72
72
|
|
|
73
73
|
return self
|
|
@@ -47,15 +47,15 @@ class SwitchBindableUi(BindableUi[ui.switch]):
|
|
|
47
47
|
def value(self):
|
|
48
48
|
return self.element.value
|
|
49
49
|
|
|
50
|
-
def bind_prop(self, prop: str,
|
|
50
|
+
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
51
51
|
if prop == "value":
|
|
52
|
-
return self.bind_value(
|
|
52
|
+
return self.bind_value(value)
|
|
53
53
|
|
|
54
|
-
return super().bind_prop(prop,
|
|
54
|
+
return super().bind_prop(prop, value)
|
|
55
55
|
|
|
56
|
-
def bind_value(self,
|
|
56
|
+
def bind_value(self, value: TGetterOrReadonlyRef[bool]):
|
|
57
57
|
@self._ui_effect
|
|
58
58
|
def _():
|
|
59
|
-
self.element.set_value(to_value(
|
|
59
|
+
self.element.set_value(to_value(value))
|
|
60
60
|
|
|
61
61
|
return self
|
|
@@ -33,12 +33,6 @@ class TabBindableUi(BindableUi[ui.tab]):
|
|
|
33
33
|
for key, value in bindings_kws.items():
|
|
34
34
|
self.bind_prop(key, value) # type: ignore
|
|
35
35
|
|
|
36
|
-
# def bind_prop(self, prop: str, ref_ui: TMaybeRef):
|
|
37
|
-
# if prop == "name":
|
|
38
|
-
# return self.bind_name(ref_ui)
|
|
39
|
-
|
|
40
|
-
# return super().bind_prop(prop, ref_ui)
|
|
41
|
-
|
|
42
36
|
def __bind_label(self, binding_kws: Dict, value_kws: Dict):
|
|
43
37
|
name_ref = binding_kws.get("name") or value_kws.get("name")
|
|
44
38
|
label_ref = binding_kws.get("label") or value_kws.get("label")
|
|
@@ -49,9 +43,3 @@ class TabBindableUi(BindableUi[ui.tab]):
|
|
|
49
43
|
to_value(label_ref) if label_ref is not None else to_value(name_ref)
|
|
50
44
|
)
|
|
51
45
|
self.element.update()
|
|
52
|
-
|
|
53
|
-
# def bind_name(self, ref_ui: TMaybeRef):
|
|
54
|
-
# @self._ui_effect
|
|
55
|
-
# def _():
|
|
56
|
-
# self.element._props["name"] = to_value(ref_ui)
|
|
57
|
-
# self.element.update()
|