ex4nicegui 0.4.6__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/index.py +1 -1
- ex4nicegui/reactive/officials/base.py +79 -4
- ex4nicegui/utils/signals.py +4 -4
- {ex4nicegui-0.4.6.dist-info → ex4nicegui-0.4.7.dist-info}/METADATA +2 -2
- {ex4nicegui-0.4.6.dist-info → ex4nicegui-0.4.7.dist-info}/RECORD +9 -9
- {ex4nicegui-0.4.6.dist-info → ex4nicegui-0.4.7.dist-info}/LICENSE +0 -0
- {ex4nicegui-0.4.6.dist-info → ex4nicegui-0.4.7.dist-info}/WHEEL +0 -0
- {ex4nicegui-0.4.6.dist-info → ex4nicegui-0.4.7.dist-info}/top_level.txt +0 -0
ex4nicegui/__init__.py
CHANGED
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:
|
|
@@ -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
|
|
ex4nicegui/utils/signals.py
CHANGED
|
@@ -96,7 +96,7 @@ def to_value(maybe_ref: _TMaybeRef[T]) -> T:
|
|
|
96
96
|
def to_ref(maybe_ref: _TMaybeRef[T]):
|
|
97
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
98
|
|
|
99
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/
|
|
99
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#to_ref
|
|
100
100
|
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#to_ref
|
|
101
101
|
|
|
102
102
|
|
|
@@ -141,7 +141,7 @@ def effect(
|
|
|
141
141
|
) -> signe_utils._TEffect_Fn[None]:
|
|
142
142
|
"""Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed.
|
|
143
143
|
|
|
144
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/
|
|
144
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#effect
|
|
145
145
|
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#effect
|
|
146
146
|
|
|
147
147
|
|
|
@@ -192,7 +192,7 @@ def ref_computed(
|
|
|
192
192
|
) -> ReadonlyRef[T]:
|
|
193
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
194
|
|
|
195
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/
|
|
195
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#ref_computed
|
|
196
196
|
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#ref_computed
|
|
197
197
|
|
|
198
198
|
|
|
@@ -291,7 +291,7 @@ def on(
|
|
|
291
291
|
):
|
|
292
292
|
"""Watches one or more reactive data sources and invokes a callback function when the sources change.
|
|
293
293
|
|
|
294
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/
|
|
294
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#on
|
|
295
295
|
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#on
|
|
296
296
|
|
|
297
297
|
|
|
@@ -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
4
|
ex4nicegui/bi/dataSourceFacade.py,sha256=W2i3gacEJhzClyRWuPSm9O4K-x---257vY9eO92gUyU,8757
|
|
5
|
-
ex4nicegui/bi/index.py,sha256=
|
|
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
|
|
@@ -63,7 +63,7 @@ ex4nicegui/reactive/mermaid/mermaid.js,sha256=Ds5VevGWZE1_N0WKf-uITd8xSCO9gQzVUs
|
|
|
63
63
|
ex4nicegui/reactive/mermaid/mermaid.py,sha256=6bJHK0hjkHKlGZRi994jj3az7Ym30vmyCelYCE2E5TI,2058
|
|
64
64
|
ex4nicegui/reactive/officials/__init__.py,sha256=8xPx079EFXpEWtEc1vCbgQJt1TRZuRf91YOaqhkyRIo,1527
|
|
65
65
|
ex4nicegui/reactive/officials/aggrid.py,sha256=-qWUyZjJMHic2ogoA3bk0hnusZEkvN3qDya0tu75PgE,2757
|
|
66
|
-
ex4nicegui/reactive/officials/base.py,sha256=
|
|
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
|
|
@@ -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
|