pgwidgets-python 0.4.2__tar.gz → 0.4.3__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.
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/PKG-INFO +2 -2
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/WhatsNew.rst +26 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/widgets.rst +5 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/all_widgets.py +3 -1
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/all_widgets_async.py +95 -27
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/async_/application.py +4 -3
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/async_/widget.py +30 -3
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/extras/file_browser.py +3 -3
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/method_types.py +8 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/sync/application.py +4 -3
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/sync/widget.py +30 -2
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets_python.egg-info/PKG-INFO +2 -2
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets_python.egg-info/requires.txt +1 -1
- pgwidgets_python-0.4.3/pgwidgets_python.egg-info/scm_version.json +8 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pyproject.toml +8 -5
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_async_session.py +0 -1
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_defs.py +2 -2
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_protocol.py +0 -2
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_reconstruct.py +17 -13
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_session.py +21 -7
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_stateful.py +19 -5
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_tree_model.py +44 -0
- pgwidgets_python-0.4.2/pgwidgets_python.egg-info/scm_version.json +0 -8
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/.flake8 +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/.github/workflows/tests.yml +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/.gitignore +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/.readthedocs.yaml +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/LICENSE.md +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/README.md +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/Makefile +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/api/async.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/api/index.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/api/sync.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/architecture.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/async.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/callbacks.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/conf.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/extras.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/getting-started.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/index.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/subclassing.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/sync.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/utilities.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/docs/web-servers.rst +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/README.md +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/demo_async.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/demo_sync.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/demo_treeview.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/flask-multi-process/README.md +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/flask-multi-process/gunicorn.conf.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/flask-multi-process/nginx.conf +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/flask-multi-process/server.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/examples/flask-multi-process/user_app.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/__init__.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/_json.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/async_/Widgets.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/async_/__init__.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/buffer.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/callbacks.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/defs.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/extras/__init__.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/icons/pgw-python-logo.png +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/sync/Widgets.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/sync/__init__.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/sync/text_source.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/text_model.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets/tree_model.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets_python.egg-info/SOURCES.txt +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets_python.egg-info/dependency_links.txt +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets_python.egg-info/scm_file_list.json +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/pgwidgets_python.egg-info/top_level.txt +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/setup.cfg +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/test_pg2.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/__init__.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_extras.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_fonts.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_resolve_kwargs.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_text_source.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tests/test_widget_classes.py +0 -0
- {pgwidgets_python-0.4.2 → pgwidgets_python-0.4.3}/tools/sync_async_tree_model.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pgwidgets-python
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Python bindings for the pgwidgets JavaScript widget library
|
|
5
5
|
Author: PGWidgets Developers
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -17,7 +17,7 @@ Classifier: Topic :: Software Development :: User Interfaces
|
|
|
17
17
|
Requires-Python: >=3.12
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE.md
|
|
20
|
-
Requires-Dist: pgwidgets-js>=0.4.
|
|
20
|
+
Requires-Dist: pgwidgets-js>=0.4.3
|
|
21
21
|
Requires-Dist: websockets>=12
|
|
22
22
|
Provides-Extra: dev
|
|
23
23
|
Requires-Dist: sphinx; extra == "dev"
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
What's New
|
|
2
2
|
==========
|
|
3
3
|
|
|
4
|
+
Recent changes — since ``v0.4.2``
|
|
5
|
+
---------------------------------
|
|
6
|
+
|
|
7
|
+
TreeView / TableView: a column can opt out of the header-click sort
|
|
8
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
9
|
+
|
|
10
|
+
A column descriptor can carry ``"sortable": False`` to take that column
|
|
11
|
+
out of the header-click sort on an otherwise sortable table. It guards
|
|
12
|
+
against an accidental sort on a column whose values are all equal --
|
|
13
|
+
the sort leaves nothing on screen to show it happened, and the next
|
|
14
|
+
edit in that column re-sorts the rows and makes the edited row jump.
|
|
15
|
+
The flag gates the user's click only, so ``sort_by_column()`` still
|
|
16
|
+
works on an opted-out column. Nothing changed on this side -- column
|
|
17
|
+
descriptors go to the browser as given -- but the browser honours the
|
|
18
|
+
flag from pgwidgets-js 0.4.3, which the dependency floor now requires.
|
|
19
|
+
|
|
20
|
+
TreeView / TableView: the column list is a private copy
|
|
21
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
22
|
+
|
|
23
|
+
``set_columns(columns)`` and the ``columns=`` constructor option now
|
|
24
|
+
keep a copy of the list they are given, as ``set_tree()`` and
|
|
25
|
+
``set_rows()`` already did. ``insert_column()``, ``append_column()``
|
|
26
|
+
and ``delete_column()`` edit the stored list in place, and before this
|
|
27
|
+
they edited the caller's list along with it; equally, a caller that
|
|
28
|
+
kept editing its own list changed what a reconnect replayed.
|
|
29
|
+
|
|
4
30
|
Recent changes — since ``v0.4.0``
|
|
5
31
|
---------------------------------
|
|
6
32
|
|
|
@@ -663,6 +663,11 @@ Each column is described by a dict with the following keys:
|
|
|
663
663
|
- ``editable`` -- whether cells in the column can be edited via
|
|
664
664
|
double-click.
|
|
665
665
|
- ``icon_size`` -- pixel size for icon columns (default 16).
|
|
666
|
+
- ``sortable`` -- ``False`` takes the column out of the header-click
|
|
667
|
+
sort on a table built with ``sortable=True``. It can only narrow:
|
|
668
|
+
``True`` does not make a column sortable on a table that is not.
|
|
669
|
+
``sort_by_column()`` still works on the column. Needs pgwidgets-js
|
|
670
|
+
0.4.3.
|
|
666
671
|
|
|
667
672
|
Tree shape (``set_tree``)
|
|
668
673
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
@@ -142,7 +142,7 @@ def on_session(session):
|
|
|
142
142
|
content.add_widget(W.Label("Editable:"), 0)
|
|
143
143
|
combo2 = W.ComboBox(editable=True, dropdown_limit=5)
|
|
144
144
|
for c in ["Red", "Orange", "Yellow", "Green", "Blue",
|
|
145
|
-
|
|
145
|
+
"Indigo", "Violet"]:
|
|
146
146
|
combo2.append_text(c)
|
|
147
147
|
combo2.on("activated",
|
|
148
148
|
lambda idx, text: lbl.set_text(f"Entered: {text}"))
|
|
@@ -417,6 +417,7 @@ def on_session(session):
|
|
|
417
417
|
lambda child, idx: lbl.set_text(f"Switched to tab {idx}"))
|
|
418
418
|
add_btn = W.Button("Add Tab")
|
|
419
419
|
tab_counter = [3]
|
|
420
|
+
|
|
420
421
|
def on_add_tab():
|
|
421
422
|
tab_counter[0] += 1
|
|
422
423
|
n = tab_counter[0]
|
|
@@ -474,6 +475,7 @@ def on_session(session):
|
|
|
474
475
|
hbox = W.HBox(spacing=4)
|
|
475
476
|
btn_add = W.Button("Add Row")
|
|
476
477
|
row_counter = [8]
|
|
478
|
+
|
|
477
479
|
def on_add_row():
|
|
478
480
|
row_counter[0] += 1
|
|
479
481
|
table.append_row({
|
|
@@ -41,6 +41,7 @@ async def main():
|
|
|
41
41
|
|
|
42
42
|
async def on_cascade():
|
|
43
43
|
await mdi.cascade_windows()
|
|
44
|
+
|
|
44
45
|
async def on_tile():
|
|
45
46
|
await mdi.tile_windows()
|
|
46
47
|
await cascade_action.on("activated", on_cascade)
|
|
@@ -97,10 +98,12 @@ async def main():
|
|
|
97
98
|
hbox = await W.HBox(spacing=6)
|
|
98
99
|
lbl = await W.Label("")
|
|
99
100
|
btn_a = await W.Button("Button A")
|
|
101
|
+
|
|
100
102
|
async def on_a():
|
|
101
103
|
await lbl.set_text("Button A clicked")
|
|
102
104
|
await btn_a.on("activated", on_a)
|
|
103
105
|
btn_b = await W.Button("Button B")
|
|
106
|
+
|
|
104
107
|
async def on_b():
|
|
105
108
|
await lbl.set_text("Button B clicked")
|
|
106
109
|
await btn_b.on("activated", on_b)
|
|
@@ -108,7 +111,8 @@ async def main():
|
|
|
108
111
|
await hbox.add_widget(btn_b, 0)
|
|
109
112
|
await content.add_widget(hbox, 0)
|
|
110
113
|
await content.add_widget(lbl, 1)
|
|
111
|
-
await mdi.add_widget(
|
|
114
|
+
await mdi.add_widget(
|
|
115
|
+
content,
|
|
112
116
|
{"title": "Button", "width": 300, "height": 120,
|
|
113
117
|
"x": pos[0], "y": pos[1]})
|
|
114
118
|
|
|
@@ -116,16 +120,19 @@ async def main():
|
|
|
116
120
|
content = await W.VBox(spacing=4, padding=8)
|
|
117
121
|
lbl = await W.Label("")
|
|
118
122
|
cb1 = await W.CheckBox("Option 1")
|
|
123
|
+
|
|
119
124
|
async def on_cb1(val):
|
|
120
125
|
await lbl.set_text(
|
|
121
126
|
f"Option 1: {'ON' if val else 'OFF'}")
|
|
122
127
|
await cb1.on("activated", on_cb1)
|
|
123
128
|
cb2 = await W.CheckBox("Option 2")
|
|
129
|
+
|
|
124
130
|
async def on_cb2(val):
|
|
125
131
|
await lbl.set_text(
|
|
126
132
|
f"Option 2: {'ON' if val else 'OFF'}")
|
|
127
133
|
await cb2.on("activated", on_cb2)
|
|
128
134
|
cb3 = await W.CheckBox("Option 3")
|
|
135
|
+
|
|
129
136
|
async def on_cb3(val):
|
|
130
137
|
await lbl.set_text(
|
|
131
138
|
f"Option 3: {'ON' if val else 'OFF'}")
|
|
@@ -134,7 +141,8 @@ async def main():
|
|
|
134
141
|
await content.add_widget(cb2, 0)
|
|
135
142
|
await content.add_widget(cb3, 0)
|
|
136
143
|
await content.add_widget(lbl, 1)
|
|
137
|
-
await mdi.add_widget(
|
|
144
|
+
await mdi.add_widget(
|
|
145
|
+
content,
|
|
138
146
|
{"title": "CheckBox", "width": 250, "height": 160,
|
|
139
147
|
"x": pos[0], "y": pos[1]})
|
|
140
148
|
|
|
@@ -144,9 +152,10 @@ async def main():
|
|
|
144
152
|
await content.add_widget(await W.Label("Pick-only:"), 0)
|
|
145
153
|
combo1 = await W.ComboBox()
|
|
146
154
|
for f in ["Apple", "Banana", "Cherry", "Date",
|
|
147
|
-
|
|
155
|
+
"Elderberry"]:
|
|
148
156
|
await combo1.append_text(f)
|
|
149
157
|
await combo1.set_index(0)
|
|
158
|
+
|
|
150
159
|
async def on_combo1(idx, text):
|
|
151
160
|
await lbl.set_text(f"Picked: {text}")
|
|
152
161
|
await combo1.on("activated", on_combo1)
|
|
@@ -154,14 +163,16 @@ async def main():
|
|
|
154
163
|
await content.add_widget(await W.Label("Editable:"), 0)
|
|
155
164
|
combo2 = await W.ComboBox(editable=True, dropdown_limit=5)
|
|
156
165
|
for c in ["Red", "Orange", "Yellow", "Green", "Blue",
|
|
157
|
-
|
|
166
|
+
"Indigo", "Violet"]:
|
|
158
167
|
await combo2.append_text(c)
|
|
168
|
+
|
|
159
169
|
async def on_combo2(idx, text):
|
|
160
170
|
await lbl.set_text(f"Entered: {text}")
|
|
161
171
|
await combo2.on("activated", on_combo2)
|
|
162
172
|
await content.add_widget(combo2, 0)
|
|
163
173
|
await content.add_widget(lbl, 1)
|
|
164
|
-
await mdi.add_widget(
|
|
174
|
+
await mdi.add_widget(
|
|
175
|
+
content,
|
|
165
176
|
{"title": "ComboBox", "width": 280, "height": 200,
|
|
166
177
|
"x": pos[0], "y": pos[1]})
|
|
167
178
|
|
|
@@ -169,6 +180,7 @@ async def main():
|
|
|
169
180
|
content = await W.HBox(spacing=8, padding=8)
|
|
170
181
|
lbl = await W.Label("50")
|
|
171
182
|
dial1 = await W.Dial(min=0, max=100, value=50, track=True)
|
|
183
|
+
|
|
172
184
|
async def on_dial(val):
|
|
173
185
|
await lbl.set_text(str(val))
|
|
174
186
|
await dial1.on("activated", on_dial)
|
|
@@ -177,7 +189,8 @@ async def main():
|
|
|
177
189
|
await content.add_widget(dial1, 0)
|
|
178
190
|
await content.add_widget(dial2, 0)
|
|
179
191
|
await content.add_widget(lbl, 1)
|
|
180
|
-
await mdi.add_widget(
|
|
192
|
+
await mdi.add_widget(
|
|
193
|
+
content,
|
|
181
194
|
{"title": "Dial", "width": 320, "height": 160,
|
|
182
195
|
"x": pos[0], "y": pos[1]})
|
|
183
196
|
|
|
@@ -190,7 +203,8 @@ async def main():
|
|
|
190
203
|
await content.add_widget(exp1, 0)
|
|
191
204
|
await content.add_widget(exp2, 0)
|
|
192
205
|
await content.add_widget(await W.Label(""), 1)
|
|
193
|
-
await mdi.add_widget(
|
|
206
|
+
await mdi.add_widget(
|
|
207
|
+
content,
|
|
194
208
|
{"title": "Expander", "width": 280, "height": 180,
|
|
195
209
|
"x": pos[0], "y": pos[1]})
|
|
196
210
|
|
|
@@ -204,7 +218,8 @@ async def main():
|
|
|
204
218
|
await W.Label("More framed content."))
|
|
205
219
|
await content.add_widget(frame1, 1)
|
|
206
220
|
await content.add_widget(frame2, 1)
|
|
207
|
-
await mdi.add_widget(
|
|
221
|
+
await mdi.add_widget(
|
|
222
|
+
content,
|
|
208
223
|
{"title": "Frame", "width": 280, "height": 200,
|
|
209
224
|
"x": pos[0], "y": pos[1]})
|
|
210
225
|
|
|
@@ -215,6 +230,7 @@ async def main():
|
|
|
215
230
|
for r in range(3):
|
|
216
231
|
for c in range(3):
|
|
217
232
|
btn = await W.Button(f"({r},{c})")
|
|
233
|
+
|
|
218
234
|
async def on_grid(_r=r, _c=c):
|
|
219
235
|
await lbl.set_text(
|
|
220
236
|
f"Clicked row={_r} col={_c}")
|
|
@@ -222,7 +238,8 @@ async def main():
|
|
|
222
238
|
await grid.add_widget(btn, r, c)
|
|
223
239
|
await content.add_widget(grid, 1)
|
|
224
240
|
await content.add_widget(lbl, 0)
|
|
225
|
-
await mdi.add_widget(
|
|
241
|
+
await mdi.add_widget(
|
|
242
|
+
content,
|
|
226
243
|
{"title": "GridBox", "width": 280, "height": 200,
|
|
227
244
|
"x": pos[0], "y": pos[1]})
|
|
228
245
|
|
|
@@ -238,7 +255,8 @@ async def main():
|
|
|
238
255
|
await content.add_widget(lbl2, 0)
|
|
239
256
|
await content.add_widget(lbl3, 0)
|
|
240
257
|
await content.add_widget(await W.Label(""), 1)
|
|
241
|
-
await mdi.add_widget(
|
|
258
|
+
await mdi.add_widget(
|
|
259
|
+
content,
|
|
242
260
|
{"title": "Label", "width": 260, "height": 150,
|
|
243
261
|
"x": pos[0], "y": pos[1]})
|
|
244
262
|
|
|
@@ -248,6 +266,7 @@ async def main():
|
|
|
248
266
|
await pb.set_value(0.65)
|
|
249
267
|
slider = await W.Slider(min=0, max=100, value=65,
|
|
250
268
|
track=True)
|
|
269
|
+
|
|
251
270
|
async def on_pb_slider(val):
|
|
252
271
|
await pb.set_value(val / 100)
|
|
253
272
|
await slider.on("activated", on_pb_slider)
|
|
@@ -256,7 +275,8 @@ async def main():
|
|
|
256
275
|
await content.add_widget(slider, 0)
|
|
257
276
|
await content.add_widget(pb, 0)
|
|
258
277
|
await content.add_widget(await W.Label(""), 1)
|
|
259
|
-
await mdi.add_widget(
|
|
278
|
+
await mdi.add_widget(
|
|
279
|
+
content,
|
|
260
280
|
{"title": "ProgressBar", "width": 320, "height": 150,
|
|
261
281
|
"x": pos[0], "y": pos[1]})
|
|
262
282
|
|
|
@@ -264,16 +284,19 @@ async def main():
|
|
|
264
284
|
content = await W.VBox(spacing=4, padding=8)
|
|
265
285
|
lbl = await W.Label("")
|
|
266
286
|
rb1 = await W.RadioButton("Choice A")
|
|
287
|
+
|
|
267
288
|
async def on_rb1(val):
|
|
268
289
|
if val:
|
|
269
290
|
await lbl.set_text("Selected: A")
|
|
270
291
|
await rb1.on("activated", on_rb1)
|
|
271
292
|
rb2 = await W.RadioButton("Choice B", group=rb1)
|
|
293
|
+
|
|
272
294
|
async def on_rb2(val):
|
|
273
295
|
if val:
|
|
274
296
|
await lbl.set_text("Selected: B")
|
|
275
297
|
await rb2.on("activated", on_rb2)
|
|
276
298
|
rb3 = await W.RadioButton("Choice C", group=rb1)
|
|
299
|
+
|
|
277
300
|
async def on_rb3(val):
|
|
278
301
|
if val:
|
|
279
302
|
await lbl.set_text("Selected: C")
|
|
@@ -283,7 +306,8 @@ async def main():
|
|
|
283
306
|
await content.add_widget(rb2, 0)
|
|
284
307
|
await content.add_widget(rb3, 0)
|
|
285
308
|
await content.add_widget(lbl, 1)
|
|
286
|
-
await mdi.add_widget(
|
|
309
|
+
await mdi.add_widget(
|
|
310
|
+
content,
|
|
287
311
|
{"title": "RadioButton", "width": 250, "height": 160,
|
|
288
312
|
"x": pos[0], "y": pos[1]})
|
|
289
313
|
|
|
@@ -300,7 +324,8 @@ async def main():
|
|
|
300
324
|
await big.add_widget(row, 0)
|
|
301
325
|
scroll = await W.ScrollArea()
|
|
302
326
|
await scroll.set_widget(big)
|
|
303
|
-
await mdi.add_widget(
|
|
327
|
+
await mdi.add_widget(
|
|
328
|
+
scroll,
|
|
304
329
|
{"title": "ScrollArea", "width": 320, "height": 200,
|
|
305
330
|
"x": pos[0], "y": pos[1]})
|
|
306
331
|
|
|
@@ -311,6 +336,7 @@ async def main():
|
|
|
311
336
|
await W.Label("Horizontal:"), 0)
|
|
312
337
|
hsb = await W.ScrollBar(orientation="horizontal")
|
|
313
338
|
await hsb.set_thumb_percent(0.2)
|
|
339
|
+
|
|
314
340
|
async def on_hsb(pct):
|
|
315
341
|
await lbl.set_text(f"{int(pct * 100)}%")
|
|
316
342
|
await hsb.on("activated", on_hsb)
|
|
@@ -323,7 +349,8 @@ async def main():
|
|
|
323
349
|
await hbox.add_widget(vsb, 0)
|
|
324
350
|
await hbox.add_widget(lbl, 1)
|
|
325
351
|
await content.add_widget(hbox, 1)
|
|
326
|
-
await mdi.add_widget(
|
|
352
|
+
await mdi.add_widget(
|
|
353
|
+
content,
|
|
327
354
|
{"title": "ScrollBar", "width": 280, "height": 200,
|
|
328
355
|
"x": pos[0], "y": pos[1]})
|
|
329
356
|
|
|
@@ -331,11 +358,13 @@ async def main():
|
|
|
331
358
|
content = await W.VBox(spacing=6, padding=8)
|
|
332
359
|
lbl = await W.Label("")
|
|
333
360
|
sl1 = await W.Slider(min=0, max=100, value=50)
|
|
361
|
+
|
|
334
362
|
async def on_sl1(val):
|
|
335
363
|
await lbl.set_text(f"Integer: {val}")
|
|
336
364
|
await sl1.on("activated", on_sl1)
|
|
337
365
|
sl2 = await W.Slider(min=0, max=1, step=0.01, value=0.5,
|
|
338
366
|
dtype="float", track=True)
|
|
367
|
+
|
|
339
368
|
async def on_sl2(val):
|
|
340
369
|
await lbl.set_text(f"Float: {val}")
|
|
341
370
|
await sl2.on("activated", on_sl2)
|
|
@@ -346,7 +375,8 @@ async def main():
|
|
|
346
375
|
await W.Label("Float tracking (0-1):"), 0)
|
|
347
376
|
await content.add_widget(sl2, 0)
|
|
348
377
|
await content.add_widget(lbl, 1)
|
|
349
|
-
await mdi.add_widget(
|
|
378
|
+
await mdi.add_widget(
|
|
379
|
+
content,
|
|
350
380
|
{"title": "Slider", "width": 320, "height": 180,
|
|
351
381
|
"x": pos[0], "y": pos[1]})
|
|
352
382
|
|
|
@@ -356,6 +386,7 @@ async def main():
|
|
|
356
386
|
await content.add_widget(
|
|
357
387
|
await W.Label("Integer (0-100):"), 0)
|
|
358
388
|
sp1 = await W.SpinBox(min=0, max=100, step=1, value=50)
|
|
389
|
+
|
|
359
390
|
async def on_sp1(val):
|
|
360
391
|
await lbl.set_text(f"Int: {val}")
|
|
361
392
|
await sp1.on("activated", on_sp1)
|
|
@@ -364,12 +395,14 @@ async def main():
|
|
|
364
395
|
await W.Label("Float (0-1):"), 0)
|
|
365
396
|
sp2 = await W.SpinBox(min=0, max=1, step=0.05, value=0.5,
|
|
366
397
|
dtype="float")
|
|
398
|
+
|
|
367
399
|
async def on_sp2(val):
|
|
368
400
|
await lbl.set_text(f"Float: {val}")
|
|
369
401
|
await sp2.on("activated", on_sp2)
|
|
370
402
|
await content.add_widget(sp2, 0)
|
|
371
403
|
await content.add_widget(lbl, 1)
|
|
372
|
-
await mdi.add_widget(
|
|
404
|
+
await mdi.add_widget(
|
|
405
|
+
content,
|
|
373
406
|
{"title": "SpinBox", "width": 280, "height": 180,
|
|
374
407
|
"x": pos[0], "y": pos[1]})
|
|
375
408
|
|
|
@@ -392,7 +425,8 @@ async def main():
|
|
|
392
425
|
await hsplit.add_widget(p3)
|
|
393
426
|
await content.add_widget(hsplit, 1)
|
|
394
427
|
await content.add_widget(lbl, 0)
|
|
395
|
-
await mdi.add_widget(
|
|
428
|
+
await mdi.add_widget(
|
|
429
|
+
content,
|
|
396
430
|
{"title": "Splitter", "width": 360, "height": 180,
|
|
397
431
|
"x": pos[0], "y": pos[1]})
|
|
398
432
|
|
|
@@ -413,6 +447,7 @@ async def main():
|
|
|
413
447
|
btn_row = await W.HBox(spacing=4)
|
|
414
448
|
for pg, nm in pages:
|
|
415
449
|
btn = await W.Button(nm)
|
|
450
|
+
|
|
416
451
|
async def on_page(_pg=pg, _nm=nm):
|
|
417
452
|
await stack.show_widget(_pg)
|
|
418
453
|
await lbl.set_text(f"{_nm} visible")
|
|
@@ -421,7 +456,8 @@ async def main():
|
|
|
421
456
|
await content.add_widget(btn_row, 0)
|
|
422
457
|
await content.add_widget(stack, 1)
|
|
423
458
|
await content.add_widget(lbl, 0)
|
|
424
|
-
await mdi.add_widget(
|
|
459
|
+
await mdi.add_widget(
|
|
460
|
+
content,
|
|
425
461
|
{"title": "StackWidget", "width": 300, "height": 200,
|
|
426
462
|
"x": pos[0], "y": pos[1]})
|
|
427
463
|
|
|
@@ -437,11 +473,13 @@ async def main():
|
|
|
437
473
|
await pg_lbl.set_color(colors[n - 1], "#333")
|
|
438
474
|
await pg.add_widget(pg_lbl, 1)
|
|
439
475
|
await tabs.add_widget(pg, {"title": f"Tab {n}"})
|
|
476
|
+
|
|
440
477
|
async def on_page_switch(child, idx):
|
|
441
478
|
await lbl.set_text(f"Switched to tab {idx}")
|
|
442
479
|
await tabs.on("page-switch", on_page_switch)
|
|
443
480
|
add_btn = await W.Button("Add Tab")
|
|
444
481
|
tab_counter = [3]
|
|
482
|
+
|
|
445
483
|
async def on_add_tab():
|
|
446
484
|
tab_counter[0] += 1
|
|
447
485
|
n = tab_counter[0]
|
|
@@ -457,7 +495,8 @@ async def main():
|
|
|
457
495
|
await btn_row.add_widget(add_btn, 0)
|
|
458
496
|
await btn_row.add_widget(lbl, 1)
|
|
459
497
|
await content.add_widget(btn_row, 0)
|
|
460
|
-
await mdi.add_widget(
|
|
498
|
+
await mdi.add_widget(
|
|
499
|
+
content,
|
|
461
500
|
{"title": "TabWidget", "width": 350, "height": 220,
|
|
462
501
|
"x": pos[0], "y": pos[1]})
|
|
463
502
|
|
|
@@ -495,6 +534,7 @@ async def main():
|
|
|
495
534
|
{"NAME": "Heidi", "DEPT": "Engineering",
|
|
496
535
|
"SALARY": 110000},
|
|
497
536
|
])
|
|
537
|
+
|
|
498
538
|
async def on_table_sel(items):
|
|
499
539
|
if len(items) == 1:
|
|
500
540
|
await lbl.set_text(
|
|
@@ -504,6 +544,7 @@ async def main():
|
|
|
504
544
|
await lbl.set_text(
|
|
505
545
|
f"Selected: {len(items)} rows")
|
|
506
546
|
await table.on("selected", on_table_sel)
|
|
547
|
+
|
|
507
548
|
async def on_table_act(values, path):
|
|
508
549
|
await lbl.set_text(
|
|
509
550
|
f"Activated: {values.get('NAME', '')}")
|
|
@@ -511,6 +552,7 @@ async def main():
|
|
|
511
552
|
hbox = await W.HBox(spacing=4)
|
|
512
553
|
btn_add = await W.Button("Add Row")
|
|
513
554
|
row_counter = [8]
|
|
555
|
+
|
|
514
556
|
async def on_add_row():
|
|
515
557
|
row_counter[0] += 1
|
|
516
558
|
await table.append_row({
|
|
@@ -519,6 +561,7 @@ async def main():
|
|
|
519
561
|
})
|
|
520
562
|
await btn_add.on("activated", on_add_row)
|
|
521
563
|
btn_sort = await W.Button("Sort by Name")
|
|
564
|
+
|
|
522
565
|
async def on_sort():
|
|
523
566
|
await table.sort_by_column("NAME")
|
|
524
567
|
await btn_sort.on("activated", on_sort)
|
|
@@ -527,7 +570,8 @@ async def main():
|
|
|
527
570
|
await hbox.add_widget(lbl, 1)
|
|
528
571
|
await content.add_widget(hbox, 0)
|
|
529
572
|
await content.add_widget(table, 1)
|
|
530
|
-
await mdi.add_widget(
|
|
573
|
+
await mdi.add_widget(
|
|
574
|
+
content,
|
|
531
575
|
{"title": "TableView", "width": 420, "height": 280,
|
|
532
576
|
"x": pos[0], "y": pos[1]})
|
|
533
577
|
|
|
@@ -535,7 +579,8 @@ async def main():
|
|
|
535
579
|
ta = await W.TextArea(
|
|
536
580
|
"This is a multi-line text area.\n\n"
|
|
537
581
|
"Edit this text freely.")
|
|
538
|
-
await mdi.add_widget(
|
|
582
|
+
await mdi.add_widget(
|
|
583
|
+
ta,
|
|
539
584
|
{"title": "TextArea", "width": 320, "height": 200,
|
|
540
585
|
"x": pos[0], "y": pos[1]})
|
|
541
586
|
|
|
@@ -544,6 +589,7 @@ async def main():
|
|
|
544
589
|
lbl = await W.Label("Press Enter to activate.")
|
|
545
590
|
entry = await W.TextEntry(text="Type here",
|
|
546
591
|
linehistory=10)
|
|
592
|
+
|
|
547
593
|
async def on_entry(text):
|
|
548
594
|
await lbl.set_text(f"Entered: {text}")
|
|
549
595
|
await entry.on("activated", on_entry)
|
|
@@ -551,12 +597,14 @@ async def main():
|
|
|
551
597
|
await content.add_widget(
|
|
552
598
|
await W.Label("Password:"), 0)
|
|
553
599
|
pw = await W.TextEntry(password=True)
|
|
600
|
+
|
|
554
601
|
async def on_pw(text):
|
|
555
602
|
await lbl.set_text(f"Password: {text}")
|
|
556
603
|
await pw.on("activated", on_pw)
|
|
557
604
|
await content.add_widget(pw, 0)
|
|
558
605
|
await content.add_widget(lbl, 1)
|
|
559
|
-
await mdi.add_widget(
|
|
606
|
+
await mdi.add_widget(
|
|
607
|
+
content,
|
|
560
608
|
{"title": "TextEntry", "width": 300, "height": 160,
|
|
561
609
|
"x": pos[0], "y": pos[1]})
|
|
562
610
|
|
|
@@ -565,12 +613,14 @@ async def main():
|
|
|
565
613
|
lbl = await W.Label("Press Enter or click Set.")
|
|
566
614
|
tes = await W.TextEntrySet(text="Set", value="Hello",
|
|
567
615
|
linehistory=5)
|
|
616
|
+
|
|
568
617
|
async def on_tes(text):
|
|
569
618
|
await lbl.set_text(f"Value: {text}")
|
|
570
619
|
await tes.on("activated", on_tes)
|
|
571
620
|
await content.add_widget(tes, 0)
|
|
572
621
|
await content.add_widget(lbl, 1)
|
|
573
|
-
await mdi.add_widget(
|
|
622
|
+
await mdi.add_widget(
|
|
623
|
+
content,
|
|
574
624
|
{"title": "TextEntrySet", "width": 300, "height": 120,
|
|
575
625
|
"x": pos[0], "y": pos[1]})
|
|
576
626
|
|
|
@@ -581,11 +631,13 @@ async def main():
|
|
|
581
631
|
await W.Label("Independent toggles:"), 0)
|
|
582
632
|
hbox1 = await W.HBox(spacing=4)
|
|
583
633
|
tb1 = await W.ToggleButton("Bold")
|
|
634
|
+
|
|
584
635
|
async def on_tb1(st):
|
|
585
636
|
await lbl.set_text(
|
|
586
637
|
f"Bold: {'on' if st else 'off'}")
|
|
587
638
|
await tb1.on("activated", on_tb1)
|
|
588
639
|
tb2 = await W.ToggleButton("Italic")
|
|
640
|
+
|
|
589
641
|
async def on_tb2(st):
|
|
590
642
|
await lbl.set_text(
|
|
591
643
|
f"Italic: {'on' if st else 'off'}")
|
|
@@ -599,14 +651,17 @@ async def main():
|
|
|
599
651
|
tg1 = await W.ToggleButton("Left")
|
|
600
652
|
tg2 = await W.ToggleButton("Center", group=tg1)
|
|
601
653
|
tg3 = await W.ToggleButton("Right", group=tg1)
|
|
654
|
+
|
|
602
655
|
async def on_tg1(st):
|
|
603
656
|
if st:
|
|
604
657
|
await lbl.set_text("Align: Left")
|
|
605
658
|
await tg1.on("activated", on_tg1)
|
|
659
|
+
|
|
606
660
|
async def on_tg2(st):
|
|
607
661
|
if st:
|
|
608
662
|
await lbl.set_text("Align: Center")
|
|
609
663
|
await tg2.on("activated", on_tg2)
|
|
664
|
+
|
|
610
665
|
async def on_tg3(st):
|
|
611
666
|
if st:
|
|
612
667
|
await lbl.set_text("Align: Right")
|
|
@@ -616,7 +671,8 @@ async def main():
|
|
|
616
671
|
await hbox2.add_widget(tg3, 0)
|
|
617
672
|
await content.add_widget(hbox2, 0)
|
|
618
673
|
await content.add_widget(lbl, 1)
|
|
619
|
-
await mdi.add_widget(
|
|
674
|
+
await mdi.add_widget(
|
|
675
|
+
content,
|
|
620
676
|
{"title": "ToggleButton", "width": 300, "height": 180,
|
|
621
677
|
"x": pos[0], "y": pos[1]})
|
|
622
678
|
|
|
@@ -626,33 +682,39 @@ async def main():
|
|
|
626
682
|
await lbl.set_padding(8)
|
|
627
683
|
tb = await W.ToolBar()
|
|
628
684
|
act1 = await tb.add_action({"text": "New"})
|
|
685
|
+
|
|
629
686
|
async def on_new():
|
|
630
687
|
await lbl.set_text("New clicked")
|
|
631
688
|
await act1.on("activated", on_new)
|
|
632
689
|
act2 = await tb.add_action({"text": "Open"})
|
|
690
|
+
|
|
633
691
|
async def on_open():
|
|
634
692
|
await lbl.set_text("Open clicked")
|
|
635
693
|
await act2.on("activated", on_open)
|
|
636
694
|
act3 = await tb.add_action({"text": "Save"})
|
|
695
|
+
|
|
637
696
|
async def on_save():
|
|
638
697
|
await lbl.set_text("Save clicked")
|
|
639
698
|
await act3.on("activated", on_save)
|
|
640
699
|
await tb.add_separator()
|
|
641
700
|
tog1 = await tb.add_action(
|
|
642
701
|
{"text": "B", "toggle": True})
|
|
702
|
+
|
|
643
703
|
async def on_bold(st):
|
|
644
704
|
await lbl.set_text(
|
|
645
705
|
f"Bold: {'on' if st else 'off'}")
|
|
646
706
|
await tog1.on("activated", on_bold)
|
|
647
707
|
tog2 = await tb.add_action(
|
|
648
708
|
{"text": "I", "toggle": True})
|
|
709
|
+
|
|
649
710
|
async def on_italic(st):
|
|
650
711
|
await lbl.set_text(
|
|
651
712
|
f"Italic: {'on' if st else 'off'}")
|
|
652
713
|
await tog2.on("activated", on_italic)
|
|
653
714
|
await content.add_widget(tb, 0)
|
|
654
715
|
await content.add_widget(lbl, 1)
|
|
655
|
-
await mdi.add_widget(
|
|
716
|
+
await mdi.add_widget(
|
|
717
|
+
content,
|
|
656
718
|
{"title": "ToolBar", "width": 350, "height": 120,
|
|
657
719
|
"x": pos[0], "y": pos[1]})
|
|
658
720
|
|
|
@@ -692,6 +754,7 @@ async def main():
|
|
|
692
754
|
"song2.flac": {"TYPE": "FLAC", "SIZE": 32000},
|
|
693
755
|
},
|
|
694
756
|
})
|
|
757
|
+
|
|
695
758
|
async def on_tree_sel(items):
|
|
696
759
|
if len(items) == 1:
|
|
697
760
|
await lbl.set_text(
|
|
@@ -700,15 +763,18 @@ async def main():
|
|
|
700
763
|
await lbl.set_text(
|
|
701
764
|
f"Selected: {len(items)} items")
|
|
702
765
|
await tree.on("selected", on_tree_sel)
|
|
766
|
+
|
|
703
767
|
async def on_tree_act(values, path):
|
|
704
768
|
await lbl.set_text(f"Activated: {path}")
|
|
705
769
|
await tree.on("activated", on_tree_act)
|
|
706
770
|
hbox = await W.HBox(spacing=4)
|
|
707
771
|
btn_exp = await W.Button("Expand All")
|
|
772
|
+
|
|
708
773
|
async def on_exp():
|
|
709
774
|
await tree.expand_all()
|
|
710
775
|
await btn_exp.on("activated", on_exp)
|
|
711
776
|
btn_col = await W.Button("Collapse All")
|
|
777
|
+
|
|
712
778
|
async def on_col():
|
|
713
779
|
await tree.collapse_all()
|
|
714
780
|
await btn_col.on("activated", on_col)
|
|
@@ -717,7 +783,8 @@ async def main():
|
|
|
717
783
|
await hbox.add_widget(lbl, 1)
|
|
718
784
|
await content.add_widget(hbox, 0)
|
|
719
785
|
await content.add_widget(tree, 1)
|
|
720
|
-
await mdi.add_widget(
|
|
786
|
+
await mdi.add_widget(
|
|
787
|
+
content,
|
|
721
788
|
{"title": "TreeView", "width": 420, "height": 300,
|
|
722
789
|
"x": pos[0], "y": pos[1]})
|
|
723
790
|
|
|
@@ -754,7 +821,8 @@ async def main():
|
|
|
754
821
|
await W.Label("VBox - vertical:"), 0)
|
|
755
822
|
await content.add_widget(inner, 1)
|
|
756
823
|
await content.add_widget(lbl, 0)
|
|
757
|
-
await mdi.add_widget(
|
|
824
|
+
await mdi.add_widget(
|
|
825
|
+
content,
|
|
758
826
|
{"title": "VBox / HBox", "width": 360, "height": 280,
|
|
759
827
|
"x": pos[0], "y": pos[1]})
|
|
760
828
|
|
|
@@ -28,10 +28,10 @@ from pgwidgets_js import get_static_path, get_remote_html
|
|
|
28
28
|
from pgwidgets._json import JsonEncoder
|
|
29
29
|
from pgwidgets.defs import WIDGETS
|
|
30
30
|
from pgwidgets.method_types import (
|
|
31
|
-
SPECIAL_SETTERS, FIXED_SETTERS,
|
|
31
|
+
SPECIAL_SETTERS, FIXED_SETTERS,
|
|
32
32
|
STATE_SYNC_CALLBACKS, STATE_SYNC_REQUIRES_OPTION,
|
|
33
33
|
WIDGET_CALLBACK_SYNC, POST_CHILDREN_STATE_KEYS, ITEM_LIST_CONFIG,
|
|
34
|
-
CHILD_CLOSE_CALLBACKS,
|
|
34
|
+
CHILD_CLOSE_CALLBACKS,
|
|
35
35
|
TREE_OVERRIDE_REPLAY, colour_batches, JS_ONLY_METHODS,
|
|
36
36
|
coalesce_colour_calls,
|
|
37
37
|
BINARY_STATE_KEYS, _send_binary_auto,
|
|
@@ -622,7 +622,6 @@ class Session:
|
|
|
622
622
|
self._next_wid = js_next
|
|
623
623
|
return result
|
|
624
624
|
|
|
625
|
-
|
|
626
625
|
def _push(self, wid, method, *args):
|
|
627
626
|
"""Push a silent call to all browsers except the callback source.
|
|
628
627
|
Fire-and-forget: no result is awaited."""
|
|
@@ -795,6 +794,7 @@ class Session:
|
|
|
795
794
|
"method": method,
|
|
796
795
|
"args": list(args),
|
|
797
796
|
}, cls=JsonEncoder)
|
|
797
|
+
|
|
798
798
|
async def _pair(ws):
|
|
799
799
|
await ws.send(header)
|
|
800
800
|
await ws.send(data)
|
|
@@ -1842,6 +1842,7 @@ class Application:
|
|
|
1842
1842
|
asyncio.ensure_future(do_reconstruct())
|
|
1843
1843
|
else:
|
|
1844
1844
|
self._logger.info(f"Session {session.id} connected.")
|
|
1845
|
+
|
|
1845
1846
|
async def do_connect():
|
|
1846
1847
|
# Replay fonts before the user callback so any
|
|
1847
1848
|
# widget the user builds with ``set_font(family,
|