ex4nicegui 0.4.6__tar.gz → 0.4.7__tar.gz
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-0.4.6 → ex4nicegui-0.4.7}/PKG-INFO +1 -1
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/README.md +95 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/__init__.py +1 -1
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/index.py +1 -1
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/base.py +79 -4
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/utils/signals.py +4 -4
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui.egg-info/PKG-INFO +1 -1
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui.egg-info/requires.txt +1 -1
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/setup.py +1 -1
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/LICENSE +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/dataSource.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/dataSourceFacade.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/containers.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/layouts.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/models.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/text.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_aggrid.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_date_picker.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_date_picker.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_echarts.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_radio.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_range.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_select.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_slider.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/elements/ui_table.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/protocols.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/bi/types.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/experimental_/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/experimental_/gridLayout/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/experimental_/gridLayout/index.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/gridFlex/GridFlex.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/gridFlex/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/gridFlex/gridFlex.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/gridFlex/utils.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/rxFlex/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/rxFlex/index.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/layout/rxFlex/types.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/EChartsComponent/ECharts.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/EChartsComponent/ECharts.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/EChartsComponent/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/UseDraggable/UseDraggable.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/UseDraggable/UseDraggable.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/UseDraggable/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/__index.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/drawer.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/dropZone/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/dropZone/dropZone.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/dropZone/dropZone.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/fileWatcher.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-color.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-dispatch.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-drag.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-ease.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-interpolate.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-selection.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-timer.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-transition.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/libs/d3/d3-zoom.ems.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/local_file_picker.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/mermaid/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/mermaid/mermaid.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/mermaid/mermaid.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/aggrid.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/button.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/card.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/checkbox.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/color_picker.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/column.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/date.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/drawer.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/echarts.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/expansion.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/grid.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/html.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/icon.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/image.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/input.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/label.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/number.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/radio.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/row.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/select.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/slider.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/switch.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/table.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/textarea.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/upload.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/officials/utils.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/q_pagination.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/rxui.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/useMouse/UseMouse.js +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/useMouse/UseMouse.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/useMouse/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/reactive/usePagination.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/tools/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/tools/debug.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/utils/__init__.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/utils/clientScope.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui/utils/common.py +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui.egg-info/SOURCES.txt +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui.egg-info/dependency_links.txt +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui.egg-info/not-zip-safe +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/ex4nicegui.egg-info/top_level.txt +0 -0
- {ex4nicegui-0.4.6 → ex4nicegui-0.4.7}/setup.cfg +0 -0
|
@@ -159,6 +159,93 @@ ui.run()
|
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
|
|
162
|
+
## 组件功能
|
|
163
|
+
|
|
164
|
+
### 绑定类名
|
|
165
|
+
|
|
166
|
+
所有的组件类提供 `bind_classes` 用于绑定 `class`,支持三种不同的数据结构。
|
|
167
|
+
|
|
168
|
+
绑定字典
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
bg_color = to_ref(False)
|
|
172
|
+
has_error = to_ref(False)
|
|
173
|
+
|
|
174
|
+
rxui.label("test").bind_classes({"bg-blue": bg_color, "text-red": has_error})
|
|
175
|
+
|
|
176
|
+
rxui.switch("bg_color", value=bg_color)
|
|
177
|
+
rxui.switch("has_error", value=has_error)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
字典键值为类名,对应值为 bool 的响应式变量。当响应式值为 `True`,类名应用到组件 class
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
绑定返回值为字典的响应式变量
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
bg_color = to_ref(False)
|
|
189
|
+
has_error = to_ref(False)
|
|
190
|
+
|
|
191
|
+
class_obj = ref_computed(
|
|
192
|
+
lambda: {"bg-blue": bg_color.value, "text-red": has_error.value}
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
rxui.switch("bg_color", value=bg_color)
|
|
196
|
+
rxui.switch("has_error", value=has_error)
|
|
197
|
+
rxui.label("bind to ref_computed").bind_classes(class_obj)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
绑定为列表
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
bg_color = to_ref("red")
|
|
206
|
+
bg_color_class = ref_computed(lambda: f"bg-{bg_color.value}")
|
|
207
|
+
|
|
208
|
+
text_color = to_ref("green")
|
|
209
|
+
text_color_class = ref_computed(lambda: f"text-{text_color.value}")
|
|
210
|
+
|
|
211
|
+
rxui.select(["red", "green", "yellow"], label="bg color", value=bg_color)
|
|
212
|
+
rxui.select(["red", "green", "yellow"], label="text color", value=text_color)
|
|
213
|
+
|
|
214
|
+
rxui.label("binding to arrays").bind_classes([bg_color_class, text_color_class])
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
列表中每个元素为返回类名的响应式变量
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### bind-style
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from nicegui import ui
|
|
226
|
+
from ex4nicegui.reactive import rxui
|
|
227
|
+
from ex4nicegui.utils.signals import to_ref
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
bg_color = to_ref("blue")
|
|
231
|
+
text_color = to_ref("red")
|
|
232
|
+
|
|
233
|
+
rxui.label("test").bind_style(
|
|
234
|
+
{
|
|
235
|
+
"background-color": bg_color,
|
|
236
|
+
"color": text_color,
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
rxui.select(["blue", "green", "yellow"], label="bg color", value=bg_color)
|
|
241
|
+
rxui.select(["red", "green", "yellow"], label="text color", value=text_color)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
`bind_style` 传入字典,`key` 为样式名字,`value` 为样式值,响应式字符串
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
162
249
|
## 响应式
|
|
163
250
|
|
|
164
251
|
```python
|
|
@@ -174,6 +261,8 @@ from ex4nicegui import (
|
|
|
174
261
|
```
|
|
175
262
|
常用 `to_ref`,`effect`,`ref_computed`,`on`
|
|
176
263
|
|
|
264
|
+
---
|
|
265
|
+
|
|
177
266
|
### `to_ref`
|
|
178
267
|
定义响应式对象,通过 `.value` 读写
|
|
179
268
|
```python
|
|
@@ -186,6 +275,8 @@ b.value = 'new text'
|
|
|
186
275
|
print(a.value)
|
|
187
276
|
```
|
|
188
277
|
|
|
278
|
+
---
|
|
279
|
+
|
|
189
280
|
### `effect`
|
|
190
281
|
接受一个函数,自动监控函数中使用到的响应式对象变化,从而自动执行函数
|
|
191
282
|
|
|
@@ -209,6 +300,7 @@ ui.button("change", on_click=change_value)
|
|
|
209
300
|
|
|
210
301
|
首次执行 effect ,函数`auto_run_when_ref_value`将被执行一次.之后点击按钮,改变 `a` 的值(通过 `a.value`),函数`auto_run_when_ref_value`再次执行
|
|
211
302
|
|
|
303
|
+
---
|
|
212
304
|
|
|
213
305
|
### `ref_computed`
|
|
214
306
|
与 `effect` 具备一样的功能,`ref_computed` 还能从函数中返回结果。一般用于从 `to_ref` 中进行二次计算
|
|
@@ -234,6 +326,8 @@ ui.button("change", on_click=change_value)
|
|
|
234
326
|
|
|
235
327
|
> `ref_computed` 是只读的 `to_ref`
|
|
236
328
|
|
|
329
|
+
---
|
|
330
|
+
|
|
237
331
|
### `on`
|
|
238
332
|
类似 `effect` 的功能,但是 `on` 需要明确指定监控的响应式对象
|
|
239
333
|
|
|
@@ -281,6 +375,7 @@ ui.button("change b", on_click=change_b)
|
|
|
281
375
|
|
|
282
376
|
- 参数 `onchanges` 为 True 时(默认值为 False),指定的函数不会在绑定时执行
|
|
283
377
|
|
|
378
|
+
---
|
|
284
379
|
|
|
285
380
|
## BI 模块
|
|
286
381
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -21,7 +21,7 @@ def get_data_files(base):
|
|
|
21
21
|
with open("README.md", encoding="utf8") as readme_file:
|
|
22
22
|
readme = readme_file.read()
|
|
23
23
|
|
|
24
|
-
requirements = ["signe>=0.2.
|
|
24
|
+
requirements = ["signe>=0.2.6", "nicegui>=1.4.0", "typing_extensions"]
|
|
25
25
|
|
|
26
26
|
test_requirements = ["pytest>=3", "playwright", "pandas"]
|
|
27
27
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|