ex4nicegui 0.4.5__py3-none-any.whl → 0.4.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 +1 -1
- ex4nicegui/bi/dataSourceFacade.py +75 -21
- ex4nicegui/bi/index.py +1 -1
- ex4nicegui/reactive/officials/aggrid.py +4 -9
- ex4nicegui/reactive/officials/base.py +79 -4
- ex4nicegui/reactive/officials/echarts.py +2 -0
- ex4nicegui/reactive/officials/number.py +10 -8
- ex4nicegui/reactive/officials/table.py +7 -18
- ex4nicegui/utils/signals.py +51 -0
- {ex4nicegui-0.4.5.dist-info → ex4nicegui-0.4.7.dist-info}/METADATA +2 -2
- {ex4nicegui-0.4.5.dist-info → ex4nicegui-0.4.7.dist-info}/RECORD +14 -14
- {ex4nicegui-0.4.5.dist-info → ex4nicegui-0.4.7.dist-info}/LICENSE +0 -0
- {ex4nicegui-0.4.5.dist-info → ex4nicegui-0.4.7.dist-info}/WHEEL +0 -0
- {ex4nicegui-0.4.5.dist-info → ex4nicegui-0.4.7.dist-info}/top_level.txt +0 -0
ex4nicegui/__init__.py
CHANGED
|
@@ -24,7 +24,9 @@ from .elements.ui_table import ui_table
|
|
|
24
24
|
from ex4nicegui.bi import types as bi_types
|
|
25
25
|
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
|
-
from ex4nicegui.bi.elements.models import
|
|
27
|
+
from ex4nicegui.bi.elements.models import (
|
|
28
|
+
UiResult,
|
|
29
|
+
)
|
|
28
30
|
|
|
29
31
|
_TData = TypeVar("_TData")
|
|
30
32
|
|
|
@@ -41,7 +43,9 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
41
43
|
@property
|
|
42
44
|
def filtered_data(self) -> _TData:
|
|
43
45
|
"""Data after filtering"""
|
|
44
|
-
return cast(
|
|
46
|
+
return cast(
|
|
47
|
+
_TData, self._dataSource.filtered_data
|
|
48
|
+
)
|
|
45
49
|
|
|
46
50
|
def reload(self, data, reset_filters=True):
|
|
47
51
|
"""Reload the data source with the provided new data.
|
|
@@ -55,7 +59,9 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
55
59
|
if reset_filters:
|
|
56
60
|
self.remove_filters()
|
|
57
61
|
|
|
58
|
-
def remove_filters(
|
|
62
|
+
def remove_filters(
|
|
63
|
+
self, *components: UiResult
|
|
64
|
+
):
|
|
59
65
|
"""Remove the filter from the data source"""
|
|
60
66
|
if len(components) == 0:
|
|
61
67
|
# remove all
|
|
@@ -67,7 +73,9 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
67
73
|
self,
|
|
68
74
|
column: str,
|
|
69
75
|
*,
|
|
70
|
-
sort_options: Optional[
|
|
76
|
+
sort_options: Optional[
|
|
77
|
+
bi_types._TDuplicates_column_values_sort_options
|
|
78
|
+
] = None,
|
|
71
79
|
exclude_null_value=False,
|
|
72
80
|
clearable=True,
|
|
73
81
|
multiple=True,
|
|
@@ -76,8 +84,8 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
76
84
|
"""
|
|
77
85
|
Creates a user interface select box.
|
|
78
86
|
|
|
79
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#
|
|
80
|
-
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#
|
|
87
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#ui_select
|
|
88
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#ui_select
|
|
81
89
|
|
|
82
90
|
|
|
83
91
|
Args:
|
|
@@ -89,11 +97,20 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
89
97
|
Returns:
|
|
90
98
|
SelectResult: An instance of a user interface select box.
|
|
91
99
|
"""
|
|
92
|
-
kws = {
|
|
100
|
+
kws = {
|
|
101
|
+
key: value
|
|
102
|
+
for key, value in locals().items()
|
|
103
|
+
if key not in ("kwargs")
|
|
104
|
+
}
|
|
93
105
|
kws.update(kwargs)
|
|
94
106
|
return ui_select(**kws)
|
|
95
107
|
|
|
96
|
-
def ui_aggrid(
|
|
108
|
+
def ui_aggrid(
|
|
109
|
+
self,
|
|
110
|
+
*,
|
|
111
|
+
options: Optional[Dict] = None,
|
|
112
|
+
**kwargs,
|
|
113
|
+
):
|
|
97
114
|
"""
|
|
98
115
|
Creates aggrid table.
|
|
99
116
|
|
|
@@ -107,7 +124,11 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
107
124
|
Returns:
|
|
108
125
|
ui.aggrid: aggrid table.
|
|
109
126
|
"""
|
|
110
|
-
kws = {
|
|
127
|
+
kws = {
|
|
128
|
+
key: value
|
|
129
|
+
for key, value in locals().items()
|
|
130
|
+
if key not in ("kwargs")
|
|
131
|
+
}
|
|
111
132
|
kws.update(kwargs)
|
|
112
133
|
return ui_aggrid(**kws)
|
|
113
134
|
|
|
@@ -131,7 +152,11 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
131
152
|
Returns:
|
|
132
153
|
ui.table: ui.table.
|
|
133
154
|
"""
|
|
134
|
-
kws = {
|
|
155
|
+
kws = {
|
|
156
|
+
key: value
|
|
157
|
+
for key, value in locals().items()
|
|
158
|
+
if key not in ("kwargs")
|
|
159
|
+
}
|
|
135
160
|
kws.update(kwargs)
|
|
136
161
|
return ui_table(**kws)
|
|
137
162
|
|
|
@@ -139,10 +164,14 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
139
164
|
self,
|
|
140
165
|
column: str,
|
|
141
166
|
*,
|
|
142
|
-
sort_options: Optional[
|
|
167
|
+
sort_options: Optional[
|
|
168
|
+
bi_types._TDuplicates_column_values_sort_options
|
|
169
|
+
] = None,
|
|
143
170
|
exclude_null_value=False,
|
|
144
171
|
hide_filtered=True,
|
|
145
|
-
custom_options_map: Optional[
|
|
172
|
+
custom_options_map: Optional[
|
|
173
|
+
Union[Dict, Callable[[Any], Any]]
|
|
174
|
+
] = None,
|
|
146
175
|
**kwargs,
|
|
147
176
|
):
|
|
148
177
|
"""
|
|
@@ -160,7 +189,11 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
160
189
|
Returns:
|
|
161
190
|
RadioResult: An radio Selection.
|
|
162
191
|
"""
|
|
163
|
-
kws = {
|
|
192
|
+
kws = {
|
|
193
|
+
key: value
|
|
194
|
+
for key, value in locals().items()
|
|
195
|
+
if key not in ("kwargs")
|
|
196
|
+
}
|
|
164
197
|
kws.update(kwargs)
|
|
165
198
|
return ui_radio(**kws)
|
|
166
199
|
|
|
@@ -180,7 +213,11 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
180
213
|
Returns:
|
|
181
214
|
ui.radio: An Slider.
|
|
182
215
|
"""
|
|
183
|
-
kws = {
|
|
216
|
+
kws = {
|
|
217
|
+
key: value
|
|
218
|
+
for key, value in locals().items()
|
|
219
|
+
if key not in ("kwargs")
|
|
220
|
+
}
|
|
184
221
|
kws.update(kwargs)
|
|
185
222
|
return ui_slider(**kws)
|
|
186
223
|
|
|
@@ -200,12 +237,19 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
200
237
|
Returns:
|
|
201
238
|
QRange: An Range.
|
|
202
239
|
"""
|
|
203
|
-
kws = {
|
|
240
|
+
kws = {
|
|
241
|
+
key: value
|
|
242
|
+
for key, value in locals().items()
|
|
243
|
+
if key not in ("kwargs")
|
|
244
|
+
}
|
|
204
245
|
kws.update(kwargs)
|
|
205
246
|
return ui_range(**kws)
|
|
206
247
|
|
|
207
248
|
def ui_echarts(
|
|
208
|
-
self,
|
|
249
|
+
self,
|
|
250
|
+
fn: Callable[
|
|
251
|
+
[Any], Union[Dict, "pyecharts.Base"]
|
|
252
|
+
], # pyright: ignore
|
|
209
253
|
):
|
|
210
254
|
"""Create charts
|
|
211
255
|
|
|
@@ -246,10 +290,20 @@ class DataSourceFacade(Generic[_TData]):
|
|
|
246
290
|
return ui_echarts(self, fn)
|
|
247
291
|
|
|
248
292
|
def send_filter(
|
|
249
|
-
self,
|
|
293
|
+
self,
|
|
294
|
+
element: ui.element,
|
|
295
|
+
filter: bi_types._TFilterCallback[_TData],
|
|
250
296
|
):
|
|
251
297
|
ele_id = element.id
|
|
252
|
-
key = self._dataSource.get_component_info_key(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
self._dataSource.
|
|
298
|
+
key = self._dataSource.get_component_info_key(
|
|
299
|
+
ele_id
|
|
300
|
+
)
|
|
301
|
+
if not self._dataSource._component_map.has_record(
|
|
302
|
+
key
|
|
303
|
+
):
|
|
304
|
+
self._dataSource._register_component(
|
|
305
|
+
ele_id
|
|
306
|
+
)
|
|
307
|
+
self._dataSource.send_filter(
|
|
308
|
+
ele_id, Filter(filter)
|
|
309
|
+
)
|
ex4nicegui/bi/index.py
CHANGED
|
@@ -10,7 +10,7 @@ _TData = TypeVar("_TData")
|
|
|
10
10
|
def data_source(data: Union[Callable[..., _TData], _TData]) -> DataSourceFacade[_TData]:
|
|
11
11
|
"""Create a data source
|
|
12
12
|
|
|
13
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/
|
|
13
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#bidata_source
|
|
14
14
|
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#bidata_source
|
|
15
15
|
|
|
16
16
|
Args:
|
|
@@ -4,7 +4,6 @@ from typing import (
|
|
|
4
4
|
Dict,
|
|
5
5
|
Optional,
|
|
6
6
|
)
|
|
7
|
-
import ex4nicegui.utils.common as utils_common
|
|
8
7
|
from ex4nicegui.utils.signals import (
|
|
9
8
|
effect,
|
|
10
9
|
ReadonlyRef,
|
|
@@ -25,7 +24,7 @@ class AggridBindableUi(BindableUi[ui.aggrid]):
|
|
|
25
24
|
html_columns: TMaybeRef[List[int]] = [],
|
|
26
25
|
theme: TMaybeRef[str] = "balham",
|
|
27
26
|
auto_size_columns: bool = True,
|
|
28
|
-
**org_kws
|
|
27
|
+
**org_kws,
|
|
29
28
|
) -> None:
|
|
30
29
|
kws = {
|
|
31
30
|
"options": options,
|
|
@@ -54,21 +53,17 @@ class AggridBindableUi(BindableUi[ui.aggrid]):
|
|
|
54
53
|
def from_pandas(
|
|
55
54
|
df: TMaybeRef,
|
|
56
55
|
columns_define_fn: Optional[Callable[[str], Dict]] = None,
|
|
57
|
-
**org_kws
|
|
56
|
+
**org_kws,
|
|
58
57
|
):
|
|
59
58
|
columns_define_fn = columns_define_fn or (lambda x: {})
|
|
60
59
|
if is_ref(df):
|
|
61
60
|
|
|
62
|
-
@ref_computed
|
|
63
|
-
def cp_convert_df():
|
|
64
|
-
return utils_common.convert_dataframe(df.value)
|
|
65
|
-
|
|
66
61
|
@ref_computed
|
|
67
62
|
def cp_options():
|
|
68
63
|
columnDefs = AggridBindableUi._get_columnDefs_from_dataframe(
|
|
69
|
-
|
|
64
|
+
df.value, columns_define_fn
|
|
70
65
|
)
|
|
71
|
-
rowData =
|
|
66
|
+
rowData = df.value.to_dict("records")
|
|
72
67
|
data = {"columnDefs": columnDefs, "rowData": rowData}
|
|
73
68
|
return data
|
|
74
69
|
|
|
@@ -3,12 +3,13 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import (
|
|
4
4
|
Any,
|
|
5
5
|
Callable,
|
|
6
|
+
Dict,
|
|
6
7
|
List,
|
|
7
8
|
Optional,
|
|
8
9
|
TypeVar,
|
|
9
10
|
Generic,
|
|
11
|
+
Union,
|
|
10
12
|
cast,
|
|
11
|
-
overload,
|
|
12
13
|
)
|
|
13
14
|
from typing_extensions import Self
|
|
14
15
|
from ex4nicegui.utils.signals import (
|
|
@@ -18,6 +19,10 @@ from ex4nicegui.utils.signals import (
|
|
|
18
19
|
ref_computed,
|
|
19
20
|
_TMaybeRef as TMaybeRef,
|
|
20
21
|
effect,
|
|
22
|
+
to_value,
|
|
23
|
+
is_ref,
|
|
24
|
+
on,
|
|
25
|
+
signe_utils,
|
|
21
26
|
)
|
|
22
27
|
from nicegui import Tailwind, ui
|
|
23
28
|
from nicegui.elements.mixins.color_elements import (
|
|
@@ -26,11 +31,22 @@ from nicegui.elements.mixins.color_elements import (
|
|
|
26
31
|
TAILWIND_COLORS,
|
|
27
32
|
)
|
|
28
33
|
from nicegui.elements.mixins.text_element import TextElement
|
|
34
|
+
from nicegui.elements.mixins.disableable_element import DisableableElement
|
|
35
|
+
|
|
29
36
|
|
|
30
37
|
T = TypeVar("T")
|
|
31
38
|
|
|
32
39
|
TWidget = TypeVar("TWidget", bound=ui.element)
|
|
33
40
|
|
|
41
|
+
_T_bind_classes_type_dict = Dict[str, TMaybeRef[bool]]
|
|
42
|
+
_T_bind_classes_type_ref_dict = ReadonlyRef[Dict[str, bool]]
|
|
43
|
+
_T_bind_classes_type_array = List[Union[ReadonlyRef[str], Ref[str]]]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
_T_bind_classes_type = Union[
|
|
47
|
+
_T_bind_classes_type_dict, _T_bind_classes_type_ref_dict, _T_bind_classes_type_array
|
|
48
|
+
]
|
|
49
|
+
|
|
34
50
|
|
|
35
51
|
class BindableUi(Generic[TWidget]):
|
|
36
52
|
def __init__(self, element: TWidget) -> None:
|
|
@@ -144,6 +160,68 @@ class BindableUi(Generic[TWidget]):
|
|
|
144
160
|
def clear(self) -> None:
|
|
145
161
|
cast(ui.element, self.element).clear()
|
|
146
162
|
|
|
163
|
+
def bind_classes(self, classes: _T_bind_classes_type):
|
|
164
|
+
"""data binding is manipulating an element's class list
|
|
165
|
+
|
|
166
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#bind-class-names
|
|
167
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#%E7%BB%91%E5%AE%9A%E7%B1%BB%E5%90%8D
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
classes (_T_bind_classes_type):
|
|
171
|
+
"""
|
|
172
|
+
if isinstance(classes, dict):
|
|
173
|
+
for name, ref_obj in classes.items():
|
|
174
|
+
|
|
175
|
+
@effect
|
|
176
|
+
def _(name=name, ref_obj=ref_obj):
|
|
177
|
+
if to_value(ref_obj):
|
|
178
|
+
self.classes(add=name)
|
|
179
|
+
else:
|
|
180
|
+
self.classes(remove=name)
|
|
181
|
+
|
|
182
|
+
elif isinstance(classes, (Ref, ReadonlyRef)):
|
|
183
|
+
ref_obj = to_value(classes)
|
|
184
|
+
assert isinstance(ref_obj, dict)
|
|
185
|
+
|
|
186
|
+
@effect
|
|
187
|
+
def _():
|
|
188
|
+
for name, value in to_value(classes).items():
|
|
189
|
+
if value:
|
|
190
|
+
self.classes(add=name)
|
|
191
|
+
else:
|
|
192
|
+
self.classes(remove=name)
|
|
193
|
+
elif isinstance(classes, list):
|
|
194
|
+
for ref_name in classes:
|
|
195
|
+
if is_ref(ref_name):
|
|
196
|
+
|
|
197
|
+
@on(ref_name)
|
|
198
|
+
def _(state: signe_utils.WatchedState):
|
|
199
|
+
self.classes(add=state.current, remove=state.previous)
|
|
200
|
+
else:
|
|
201
|
+
self.classes(ref_name) # type: ignore
|
|
202
|
+
|
|
203
|
+
return self
|
|
204
|
+
|
|
205
|
+
def bind_style(self, style: Dict[str, Union[ReadonlyRef[str], Ref[str]]]):
|
|
206
|
+
"""data binding is manipulating an element's style
|
|
207
|
+
|
|
208
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#bind-style
|
|
209
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#bind-style
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
style (Dict[str, Union[ReadonlyRef[str], Ref[str]]]): _description_
|
|
213
|
+
"""
|
|
214
|
+
if isinstance(style, dict):
|
|
215
|
+
for name, ref_obj in style.items():
|
|
216
|
+
if is_ref(ref_obj):
|
|
217
|
+
|
|
218
|
+
@effect
|
|
219
|
+
def _(name=name, ref_obj=ref_obj):
|
|
220
|
+
self.element._style[name] = ref_obj.value
|
|
221
|
+
self.element.update()
|
|
222
|
+
|
|
223
|
+
return self
|
|
224
|
+
|
|
147
225
|
|
|
148
226
|
class SingleValueBindableUi(BindableUi[TWidget], Generic[T, TWidget]):
|
|
149
227
|
def __init__(self, value: TMaybeRef[T], element: TWidget) -> None:
|
|
@@ -162,9 +240,6 @@ class SingleValueBindableUi(BindableUi[TWidget], Generic[T, TWidget]):
|
|
|
162
240
|
return self
|
|
163
241
|
|
|
164
242
|
|
|
165
|
-
from nicegui.elements.mixins.disableable_element import DisableableElement
|
|
166
|
-
|
|
167
|
-
|
|
168
243
|
_T_DisableableBinder = TypeVar("_T_DisableableBinder", bound=DisableableElement)
|
|
169
244
|
|
|
170
245
|
|
|
@@ -21,15 +21,10 @@ T = TypeVar("T")
|
|
|
21
21
|
class NumberBindableUi(SingleValueBindableUi[float, ui.number]):
|
|
22
22
|
@staticmethod
|
|
23
23
|
def _setup_(binder: "NumberBindableUi"):
|
|
24
|
-
def onValueChanged(e):
|
|
25
|
-
binder._ref.value = e.args # type: ignore
|
|
26
|
-
|
|
27
24
|
@effect
|
|
28
25
|
def _():
|
|
29
26
|
binder.element.value = binder.value
|
|
30
27
|
|
|
31
|
-
binder.element.on("update:modelValue", handler=onValueChanged)
|
|
32
|
-
|
|
33
28
|
def __init__(
|
|
34
29
|
self,
|
|
35
30
|
label: Optional[TMaybeRef[str]] = None,
|
|
@@ -61,13 +56,20 @@ class NumberBindableUi(SingleValueBindableUi[float, ui.number]):
|
|
|
61
56
|
|
|
62
57
|
value_kws = _convert_kws_ref2value(kws)
|
|
63
58
|
|
|
59
|
+
def inject_on_change(e):
|
|
60
|
+
self._ref.value = e.value
|
|
61
|
+
if on_change:
|
|
62
|
+
on_change(e)
|
|
63
|
+
|
|
64
|
+
value_kws.update({"on_change": inject_on_change})
|
|
65
|
+
|
|
64
66
|
element = ui.number(**value_kws)
|
|
65
67
|
element.classes("min-w-[10rem]")
|
|
66
68
|
|
|
67
|
-
super().__init__(value, element)
|
|
69
|
+
super().__init__(value, element) # type: ignore
|
|
68
70
|
|
|
69
71
|
for key, value in kws.items():
|
|
70
|
-
if is_ref(value):
|
|
71
|
-
self.bind_prop(key, value)
|
|
72
|
+
if key != "value" and is_ref(value):
|
|
73
|
+
self.bind_prop(key, value) # type: ignore
|
|
72
74
|
|
|
73
75
|
NumberBindableUi._setup_(self)
|
|
@@ -4,7 +4,6 @@ from typing import (
|
|
|
4
4
|
List,
|
|
5
5
|
Optional,
|
|
6
6
|
Dict,
|
|
7
|
-
cast,
|
|
8
7
|
)
|
|
9
8
|
from typing_extensions import Literal
|
|
10
9
|
import ex4nicegui.utils.common as utils_common
|
|
@@ -19,11 +18,6 @@ from ex4nicegui.utils.signals import (
|
|
|
19
18
|
from nicegui import ui
|
|
20
19
|
from .base import BindableUi
|
|
21
20
|
from .utils import _convert_kws_ref2value
|
|
22
|
-
from nicegui.events import (
|
|
23
|
-
GenericEventArguments,
|
|
24
|
-
TableSelectionEventArguments,
|
|
25
|
-
handle_event,
|
|
26
|
-
)
|
|
27
21
|
|
|
28
22
|
|
|
29
23
|
class TableBindableUi(BindableUi[ui.table]):
|
|
@@ -61,10 +55,10 @@ class TableBindableUi(BindableUi[ui.table]):
|
|
|
61
55
|
self._arg_row_key = row_key
|
|
62
56
|
self._selection_ref: ReadonlyRef[List[Any]] = to_ref([])
|
|
63
57
|
|
|
64
|
-
def
|
|
58
|
+
def on_selection(_):
|
|
65
59
|
self._selection_ref.value = self.element.selected # type: ignore
|
|
66
60
|
|
|
67
|
-
self.element.on("selection",
|
|
61
|
+
self.element.on("selection", on_selection)
|
|
68
62
|
|
|
69
63
|
@property
|
|
70
64
|
def selection_ref(self):
|
|
@@ -92,13 +86,9 @@ class TableBindableUi(BindableUi[ui.table]):
|
|
|
92
86
|
|
|
93
87
|
if is_ref(df):
|
|
94
88
|
|
|
95
|
-
@ref_computed
|
|
96
|
-
def cp_convert_df():
|
|
97
|
-
return utils_common.convert_dataframe(df.value)
|
|
98
|
-
|
|
99
89
|
@ref_computed
|
|
100
90
|
def cp_rows():
|
|
101
|
-
return
|
|
91
|
+
return df.value.to_dict("records")
|
|
102
92
|
|
|
103
93
|
@ref_computed
|
|
104
94
|
def cp_cols():
|
|
@@ -109,15 +99,14 @@ class TableBindableUi(BindableUi[ui.table]):
|
|
|
109
99
|
"label": col,
|
|
110
100
|
"field": col,
|
|
111
101
|
},
|
|
112
|
-
**columns_define_fn(col),
|
|
102
|
+
**columns_define_fn(col), # type: ignore
|
|
113
103
|
}
|
|
114
|
-
for col in
|
|
104
|
+
for col in df.value.columns
|
|
115
105
|
]
|
|
116
106
|
|
|
117
107
|
return TableBindableUi(cp_cols, cp_rows, **other_kws)
|
|
118
108
|
|
|
119
|
-
|
|
120
|
-
rows = df.to_dict("records")
|
|
109
|
+
rows = df.to_dict("records") # type: ignore
|
|
121
110
|
|
|
122
111
|
cols = [
|
|
123
112
|
{
|
|
@@ -128,7 +117,7 @@ class TableBindableUi(BindableUi[ui.table]):
|
|
|
128
117
|
},
|
|
129
118
|
**columns_define_fn(col),
|
|
130
119
|
}
|
|
131
|
-
for col in df.columns
|
|
120
|
+
for col in df.columns # type: ignore
|
|
132
121
|
]
|
|
133
122
|
return TableBindableUi(cols, rows, **other_kws)
|
|
134
123
|
|
ex4nicegui/utils/signals.py
CHANGED
|
@@ -94,6 +94,17 @@ def to_value(maybe_ref: _TMaybeRef[T]) -> T:
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
def to_ref(maybe_ref: _TMaybeRef[T]):
|
|
97
|
+
"""Takes an inner value and returns a reactive and mutable ref object, which has a single property .value that points to the inner value.
|
|
98
|
+
|
|
99
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#to_ref
|
|
100
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#to_ref
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
maybe_ref (_TMaybeRef[T]): _description_
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
"""
|
|
97
108
|
if is_ref(maybe_ref):
|
|
98
109
|
return cast(Ref[T], maybe_ref)
|
|
99
110
|
|
|
@@ -128,6 +139,19 @@ def effect(
|
|
|
128
139
|
debug_trigger: Optional[Callable] = None,
|
|
129
140
|
debug_name: Optional[str] = None,
|
|
130
141
|
) -> signe_utils._TEffect_Fn[None]:
|
|
142
|
+
"""Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed.
|
|
143
|
+
|
|
144
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#effect
|
|
145
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#effect
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
fn (None, optional): _description_. Defaults to ....
|
|
150
|
+
priority_level (int, optional): _description_. Defaults to 1.
|
|
151
|
+
debug_trigger (Optional[Callable], optional): _description_. Defaults to None.
|
|
152
|
+
debug_name (Optional[str], optional): _description_. Defaults to None.
|
|
153
|
+
|
|
154
|
+
"""
|
|
131
155
|
...
|
|
132
156
|
|
|
133
157
|
|
|
@@ -166,6 +190,20 @@ def ref_computed(
|
|
|
166
190
|
priority_level: int = 1,
|
|
167
191
|
debug_name: Optional[str] = None,
|
|
168
192
|
) -> ReadonlyRef[T]:
|
|
193
|
+
"""Takes a getter function and returns a readonly reactive ref object for the returned value from the getter. It can also take an object with get and set functions to create a writable ref object.
|
|
194
|
+
|
|
195
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#ref_computed
|
|
196
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#ref_computed
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
fn (Callable[[], T]): _description_
|
|
201
|
+
desc (str, optional): _description_. Defaults to "".
|
|
202
|
+
debug_trigger (Optional[Callable[..., None]], optional): _description_. Defaults to None.
|
|
203
|
+
priority_level (int, optional): _description_. Defaults to 1.
|
|
204
|
+
debug_name (Optional[str], optional): _description_. Defaults to None.
|
|
205
|
+
|
|
206
|
+
"""
|
|
169
207
|
...
|
|
170
208
|
|
|
171
209
|
|
|
@@ -251,6 +289,19 @@ def on(
|
|
|
251
289
|
priority_level=1,
|
|
252
290
|
effect_kws: Optional[Dict[str, Any]] = None,
|
|
253
291
|
):
|
|
292
|
+
"""Watches one or more reactive data sources and invokes a callback function when the sources change.
|
|
293
|
+
|
|
294
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#on
|
|
295
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#on
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
Args:
|
|
299
|
+
refs (Union[ReadonlyRef, Sequence[ReadonlyRef]]): _description_
|
|
300
|
+
onchanges (bool, optional): _description_. Defaults to False.
|
|
301
|
+
priority_level (int, optional): _description_. Defaults to 1.
|
|
302
|
+
effect_kws (Optional[Dict[str, Any]], optional): _description_. Defaults to None.
|
|
303
|
+
|
|
304
|
+
"""
|
|
254
305
|
effect_kws = effect_kws or {}
|
|
255
306
|
if not isinstance(refs, Sequence):
|
|
256
307
|
refs = [refs]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ex4nicegui
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.7
|
|
4
4
|
Summary: ...
|
|
5
5
|
Home-page:
|
|
6
6
|
Author: carson_jia
|
|
@@ -13,7 +13,7 @@ Classifier: Natural Language :: English
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.8
|
|
14
14
|
Requires-Python: >=3.8
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: signe (>=0.2.
|
|
16
|
+
Requires-Dist: signe (>=0.2.6)
|
|
17
17
|
Requires-Dist: nicegui (>=1.4.0)
|
|
18
18
|
Requires-Dist: typing-extensions
|
|
19
19
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
ex4nicegui/__init__.py,sha256=
|
|
1
|
+
ex4nicegui/__init__.py,sha256=bZbEF9bSM74gyuksehaPjdaUWmQSf6sV83wFF7YHu5w,425
|
|
2
2
|
ex4nicegui/bi/__init__.py,sha256=eu-2CuzzrcHCyKQOfoo87v6C9nSwFDdeLhjY0cRV13M,315
|
|
3
3
|
ex4nicegui/bi/dataSource.py,sha256=sQzuQvNWBf20n9cz--1OX5gxT6RUAhwrq_xTQEpSa0o,7691
|
|
4
|
-
ex4nicegui/bi/dataSourceFacade.py,sha256=
|
|
5
|
-
ex4nicegui/bi/index.py,sha256=
|
|
4
|
+
ex4nicegui/bi/dataSourceFacade.py,sha256=W2i3gacEJhzClyRWuPSm9O4K-x---257vY9eO92gUyU,8757
|
|
5
|
+
ex4nicegui/bi/index.py,sha256=ZuwFxUD1KcxBpKvTLO7CGQQ5gN7FDpaHo9tfAS3UpQ4,2067
|
|
6
6
|
ex4nicegui/bi/protocols.py,sha256=EWODxokdWI1BtAgFm3iWVVRAgOlMEoXTmfT4g24HPU4,4566
|
|
7
7
|
ex4nicegui/bi/types.py,sha256=9aX-ChGUi6HVKNdFeBnSxW2j2D98wF-WSoD6RFv8778,389
|
|
8
8
|
ex4nicegui/bi/elements/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -62,8 +62,8 @@ ex4nicegui/reactive/mermaid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
62
62
|
ex4nicegui/reactive/mermaid/mermaid.js,sha256=Ds5VevGWZE1_N0WKf-uITd8xSCO9gQzVUsmb80EajNY,2308
|
|
63
63
|
ex4nicegui/reactive/mermaid/mermaid.py,sha256=6bJHK0hjkHKlGZRi994jj3az7Ym30vmyCelYCE2E5TI,2058
|
|
64
64
|
ex4nicegui/reactive/officials/__init__.py,sha256=8xPx079EFXpEWtEc1vCbgQJt1TRZuRf91YOaqhkyRIo,1527
|
|
65
|
-
ex4nicegui/reactive/officials/aggrid.py,sha256
|
|
66
|
-
ex4nicegui/reactive/officials/base.py,sha256=
|
|
65
|
+
ex4nicegui/reactive/officials/aggrid.py,sha256=-qWUyZjJMHic2ogoA3bk0hnusZEkvN3qDya0tu75PgE,2757
|
|
66
|
+
ex4nicegui/reactive/officials/base.py,sha256=gTddy6SjoyueztAsXoHCWXLDnsoE6Uq9AyISHpRnv50,8378
|
|
67
67
|
ex4nicegui/reactive/officials/button.py,sha256=wWupfLQHcDMobPZgKs73yxXoHUaE0YWwjWyidQVmWr0,1951
|
|
68
68
|
ex4nicegui/reactive/officials/card.py,sha256=8-tBwm3xfVybolQ87i8lAYUpBV6FdaVdeSH6xu0736U,1275
|
|
69
69
|
ex4nicegui/reactive/officials/checkbox.py,sha256=i7IhJJLHAuEPxv55kQmeJTwXWtV7vlUj1KTT1rkYL3Q,1855
|
|
@@ -71,7 +71,7 @@ ex4nicegui/reactive/officials/color_picker.py,sha256=ijdqVDPjrPwbuD2bSjtBIsQI4qs
|
|
|
71
71
|
ex4nicegui/reactive/officials/column.py,sha256=3RLvVKNaDtOb8df4uS3xRfwJJPuH1ndXk_Y4Gry0Tjo,413
|
|
72
72
|
ex4nicegui/reactive/officials/date.py,sha256=Ht3j1DAbzHDzxrVb71pLBKJoTK9gmlhwiJM0kIBrM4o,2718
|
|
73
73
|
ex4nicegui/reactive/officials/drawer.py,sha256=QXFhuDGzlGapd-AXe_KQYxvmcODpfXifdOMudW0UwnA,2372
|
|
74
|
-
ex4nicegui/reactive/officials/echarts.py,sha256=
|
|
74
|
+
ex4nicegui/reactive/officials/echarts.py,sha256=oio-dLpR_HQeVdy1dRzQbdg0_N4BjtVRvLrQkvc_JBo,6469
|
|
75
75
|
ex4nicegui/reactive/officials/expansion.py,sha256=Z2aKsrtUpkO0Z4kO9kPwcu7piBcE_d62OAC2oVDFTGE,1528
|
|
76
76
|
ex4nicegui/reactive/officials/grid.py,sha256=6brGijR9ZLqOhe5r2w4BF81R8I4kJPZxZVkbQjXwlOU,925
|
|
77
77
|
ex4nicegui/reactive/officials/html.py,sha256=tHN3Vu30ckkVoT4X3MKlzUgE1p_2Ewo3IrmS-XwixdM,1676
|
|
@@ -79,13 +79,13 @@ ex4nicegui/reactive/officials/icon.py,sha256=5IwapbWHTeW30blen4BTmRQkrW5dppAbtMC
|
|
|
79
79
|
ex4nicegui/reactive/officials/image.py,sha256=UUM87GuV3y78p9TpZgYkve7cHzGQLFsaQf02UtaDINk,1507
|
|
80
80
|
ex4nicegui/reactive/officials/input.py,sha256=uYjuY4WM7lRyrXn42CQAiPMG8e7HufLrr2ZmQ-JfC8s,3419
|
|
81
81
|
ex4nicegui/reactive/officials/label.py,sha256=bOWoDiPCHJJc2x_LWYq64PytjODpMmVSn3X9Mr5HVMY,1735
|
|
82
|
-
ex4nicegui/reactive/officials/number.py,sha256=
|
|
82
|
+
ex4nicegui/reactive/officials/number.py,sha256=QpGQlkmA7wbvfS6A3RT8lxs5LznhrRQa6vnw03xdIkU,2127
|
|
83
83
|
ex4nicegui/reactive/officials/radio.py,sha256=AdJ56RwEvvauA6tMCmJnl0rZF69zvcuTj4_SmT0aD7g,2290
|
|
84
84
|
ex4nicegui/reactive/officials/row.py,sha256=ZBPITfHbJmAdAWuIZFl2H1XFS9pJam57PJ_zDZWhueE,404
|
|
85
85
|
ex4nicegui/reactive/officials/select.py,sha256=XE2RY7_3UgSiS8c_pvi7pzw7IkycbDtvPCPuSuEJzao,3262
|
|
86
86
|
ex4nicegui/reactive/officials/slider.py,sha256=FTLdh1-YWi9mpWOm_T4FpWvrNcoL7Vo6dqeCptAaH88,2696
|
|
87
87
|
ex4nicegui/reactive/officials/switch.py,sha256=iWftxOebHptztujMFsVzGJL2qIgbKPuFnPdx9k0xGIw,1997
|
|
88
|
-
ex4nicegui/reactive/officials/table.py,sha256=
|
|
88
|
+
ex4nicegui/reactive/officials/table.py,sha256=KkhVkaJk-ls-wtBtd48UajBNpwRDcVTqUr8tULBjeQg,5021
|
|
89
89
|
ex4nicegui/reactive/officials/textarea.py,sha256=svHXwd5_KzvEZfdsboqhsaNePf_N8pVjk-p0UVU0n_g,2744
|
|
90
90
|
ex4nicegui/reactive/officials/upload.py,sha256=uk5qfgGXIV8ThTR7hg5IUdOYRT9iQedogJnrVIK69z0,2337
|
|
91
91
|
ex4nicegui/reactive/officials/utils.py,sha256=9Kbhw7jFPGRyGQ6jN8GgWg2FISz-Ee4dbZtgK44PTzs,205
|
|
@@ -97,9 +97,9 @@ ex4nicegui/tools/debug.py,sha256=HCKlVzhHx5av-983ADgwgMkScKwTreSluLA7uikGYa0,488
|
|
|
97
97
|
ex4nicegui/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
98
98
|
ex4nicegui/utils/clientScope.py,sha256=gciC34QDwHlhln8dkS5IJS0YnzHE8grJRp1uFlqlLVA,1143
|
|
99
99
|
ex4nicegui/utils/common.py,sha256=7P0vboDadLun6EMxNi3br9rKJgKt0QT4sy_66cHEwb4,994
|
|
100
|
-
ex4nicegui/utils/signals.py,sha256=
|
|
101
|
-
ex4nicegui-0.4.
|
|
102
|
-
ex4nicegui-0.4.
|
|
103
|
-
ex4nicegui-0.4.
|
|
104
|
-
ex4nicegui-0.4.
|
|
105
|
-
ex4nicegui-0.4.
|
|
100
|
+
ex4nicegui/utils/signals.py,sha256=QVmrtFxIFVV_EXXn8tXZz8AAvgAwhO2cWLdvFfVHVWI,9590
|
|
101
|
+
ex4nicegui-0.4.7.dist-info/LICENSE,sha256=0KDDElS2dl-HIsWvbpy8ywbLzJMBFzXLev57LnMIZXs,1094
|
|
102
|
+
ex4nicegui-0.4.7.dist-info/METADATA,sha256=hby2SsODlZpRRT3H7KAEO8-nRz7t3c6dVZ5_p6DnM74,532
|
|
103
|
+
ex4nicegui-0.4.7.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
104
|
+
ex4nicegui-0.4.7.dist-info/top_level.txt,sha256=VFwMiO9AFjj5rfLMJwN1ipLRASk9fJXB8tM6DNrpvPQ,11
|
|
105
|
+
ex4nicegui-0.4.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|