ren-ui-python 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ren_ui/__init__.py +1 -1
- ren_ui/app.py +4 -4
- ren_ui/widgets.py +19 -19
- {ren_ui_python-0.1.0.dist-info → ren_ui_python-0.2.0.dist-info}/METADATA +1 -1
- {ren_ui_python-0.1.0.dist-info → ren_ui_python-0.2.0.dist-info}/RECORD +9 -9
- {ren_ui_python-0.1.0.dist-info → ren_ui_python-0.2.0.dist-info}/WHEEL +0 -0
- {ren_ui_python-0.1.0.dist-info → ren_ui_python-0.2.0.dist-info}/entry_points.txt +0 -0
- {ren_ui_python-0.1.0.dist-info → ren_ui_python-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {ren_ui_python-0.1.0.dist-info → ren_ui_python-0.2.0.dist-info}/top_level.txt +0 -0
ren_ui/__init__.py
CHANGED
|
@@ -4,7 +4,7 @@ from .app import Application, Event
|
|
|
4
4
|
from .resources import asset_path
|
|
5
5
|
from .widgets import Button, CheckBox, Column, Image, Label, Row, Slider, TextArea, TextInput, Window
|
|
6
6
|
|
|
7
|
-
__version__ = "0.
|
|
7
|
+
__version__ = "0.2.0"
|
|
8
8
|
__all__ = [
|
|
9
9
|
"Application", "Event", "Image", "asset_path", "Window", "Column", "Row", "Label", "Button",
|
|
10
10
|
"TextInput", "TextArea", "CheckBox", "Slider",
|
ren_ui/app.py
CHANGED
|
@@ -84,8 +84,8 @@ class Application:
|
|
|
84
84
|
if window._closed:
|
|
85
85
|
continue
|
|
86
86
|
window._closed = True
|
|
87
|
-
if window.
|
|
88
|
-
window.
|
|
87
|
+
if window.onclosed:
|
|
88
|
+
window.onclosed(Event(window, kind))
|
|
89
89
|
continue
|
|
90
90
|
if window._closed or window._closing:
|
|
91
91
|
continue
|
|
@@ -93,8 +93,8 @@ class Application:
|
|
|
93
93
|
window._decide_close(Event(window, kind))
|
|
94
94
|
continue
|
|
95
95
|
widget = window._widgets.get(view_id)
|
|
96
|
-
if widget is not None and widget.
|
|
97
|
-
widget.
|
|
96
|
+
if widget is not None and widget.onchange:
|
|
97
|
+
widget.onchange(Event(widget, kind, text, value))
|
|
98
98
|
except Exception:
|
|
99
99
|
# A failing handler must not kill the dispatcher or the app.
|
|
100
100
|
traceback.print_exc()
|
ren_ui/widgets.py
CHANGED
|
@@ -19,14 +19,14 @@ def _dimension(value, name, *, positive=False):
|
|
|
19
19
|
class Widget:
|
|
20
20
|
kind = ""
|
|
21
21
|
|
|
22
|
-
def __init__(self, text="", *,
|
|
22
|
+
def __init__(self, text="", *, onchange=None, enabled=True):
|
|
23
23
|
utf8(text)
|
|
24
|
-
if
|
|
25
|
-
raise TypeError("
|
|
24
|
+
if onchange is not None and not callable(onchange):
|
|
25
|
+
raise TypeError("onchange must be callable")
|
|
26
26
|
self._text = text
|
|
27
27
|
self._value = 0
|
|
28
28
|
self._enabled = bool(enabled)
|
|
29
|
-
self.
|
|
29
|
+
self.onchange = onchange
|
|
30
30
|
self._window = None
|
|
31
31
|
self._id = None
|
|
32
32
|
|
|
@@ -114,7 +114,7 @@ class Button(Widget):
|
|
|
114
114
|
|
|
115
115
|
def __init__(self, text, onclick=None, *, enabled=True,
|
|
116
116
|
icon: str | Path | None = None, icon_size: int = 24):
|
|
117
|
-
super().__init__(text,
|
|
117
|
+
super().__init__(text, onchange=onclick, enabled=enabled)
|
|
118
118
|
if type(icon_size) is not int or not 1 <= icon_size <= 256:
|
|
119
119
|
raise ValueError("icon_size must be an integer from 1 to 256")
|
|
120
120
|
self._icon_size = icon_size
|
|
@@ -143,7 +143,7 @@ class Button(Widget):
|
|
|
143
143
|
"""
|
|
144
144
|
if not callable(callback):
|
|
145
145
|
raise TypeError("onclick must be callable")
|
|
146
|
-
self.
|
|
146
|
+
self.onchange = callback
|
|
147
147
|
return callback
|
|
148
148
|
|
|
149
149
|
def click(self):
|
|
@@ -198,8 +198,8 @@ class Image(Widget):
|
|
|
198
198
|
class TextInput(Widget):
|
|
199
199
|
kind = "text"
|
|
200
200
|
|
|
201
|
-
def __init__(self, text="", *, label="",
|
|
202
|
-
super().__init__(text,
|
|
201
|
+
def __init__(self, text="", *, label="", onchange=None, enabled=True):
|
|
202
|
+
super().__init__(text, onchange=onchange, enabled=enabled)
|
|
203
203
|
utf8(label)
|
|
204
204
|
self.label = label
|
|
205
205
|
|
|
@@ -207,15 +207,15 @@ class TextInput(Widget):
|
|
|
207
207
|
class TextArea(Widget):
|
|
208
208
|
"""Scrollable UTF-8 text, up to 1 MiB, with native editing and undo.
|
|
209
209
|
|
|
210
|
-
Changes, including assignments to text after mounting, emit
|
|
210
|
+
Changes, including assignments to text after mounting, emit onchange.
|
|
211
211
|
wrap is a construction option; editable can be changed at runtime.
|
|
212
212
|
"""
|
|
213
213
|
kind = "textarea"
|
|
214
214
|
MAX_BYTES = 1024 * 1024
|
|
215
215
|
|
|
216
|
-
def __init__(self, text="", *,
|
|
216
|
+
def __init__(self, text="", *, onchange=None, editable=True, wrap=True):
|
|
217
217
|
self._validate_text(text)
|
|
218
|
-
super().__init__(text,
|
|
218
|
+
super().__init__(text, onchange=onchange, enabled=editable)
|
|
219
219
|
self.wrap = bool(wrap)
|
|
220
220
|
|
|
221
221
|
@staticmethod
|
|
@@ -240,8 +240,8 @@ class TextArea(Widget):
|
|
|
240
240
|
class CheckBox(Widget):
|
|
241
241
|
kind = "checkbox"
|
|
242
242
|
|
|
243
|
-
def __init__(self, text, *, checked=False,
|
|
244
|
-
super().__init__(text,
|
|
243
|
+
def __init__(self, text, *, checked=False, onchange=None, enabled=True):
|
|
244
|
+
super().__init__(text, onchange=onchange, enabled=enabled)
|
|
245
245
|
self._value = int(bool(checked))
|
|
246
246
|
|
|
247
247
|
@property
|
|
@@ -256,8 +256,8 @@ class CheckBox(Widget):
|
|
|
256
256
|
class Slider(Widget):
|
|
257
257
|
kind = "slider"
|
|
258
258
|
|
|
259
|
-
def __init__(self, text="", *, minimum=0, maximum=100, value=0,
|
|
260
|
-
super().__init__(text,
|
|
259
|
+
def __init__(self, text="", *, minimum=0, maximum=100, value=0, onchange=None):
|
|
260
|
+
super().__init__(text, onchange=onchange)
|
|
261
261
|
# The ABI carries layout/range values as floats; keep integers exact.
|
|
262
262
|
if not all(isinstance(v, int) and abs(v) <= 2**24 for v in (minimum, maximum, value)):
|
|
263
263
|
raise ValueError("slider bounds and value must be integers within +/- 2**24")
|
|
@@ -284,13 +284,13 @@ class Row(Column):
|
|
|
284
284
|
|
|
285
285
|
|
|
286
286
|
class Window:
|
|
287
|
-
def __init__(self, app, title, content, *, width=480, height=280, resizable=True, onclose=None,
|
|
287
|
+
def __init__(self, app, title, content, *, width=480, height=280, resizable=True, onclose=None, onclosed=None):
|
|
288
288
|
utf8(title)
|
|
289
289
|
if not isinstance(content, Widget):
|
|
290
290
|
raise TypeError("content must be a widget or layout")
|
|
291
|
-
if
|
|
292
|
-
raise TypeError("
|
|
293
|
-
self.app, self.content, self.
|
|
291
|
+
if onclosed is not None and not callable(onclosed):
|
|
292
|
+
raise TypeError("onclosed must be callable")
|
|
293
|
+
self.app, self.content, self.onclosed = app, content, onclosed
|
|
294
294
|
self._title = title
|
|
295
295
|
self.width = _dimension(width, "width", positive=True)
|
|
296
296
|
self.height = _dimension(height, "height", positive=True)
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
ren_ui/__init__.py,sha256=
|
|
1
|
+
ren_ui/__init__.py,sha256=b_7_kMddYdi7W0jwufgnaWuWibsgBNULD0LiWIXLmvY,432
|
|
2
2
|
ren_ui/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
3
3
|
ren_ui/_native.py,sha256=KTHsIGLHG5fVcSdfhfTS0_mHME3TjTtnKE78zRGG8WE,2907
|
|
4
|
-
ren_ui/app.py,sha256=
|
|
4
|
+
ren_ui/app.py,sha256=zkOysAxREkXn1bQKMWwZWQLSgeDNexdXsJhCOYT0amg,5635
|
|
5
5
|
ren_ui/build.py,sha256=zw_5m7AiFHw1JcpQVXvI-z8QklIg_plv8rbAHA9t2Us,13039
|
|
6
6
|
ren_ui/cli.py,sha256=btDNi185_zFyjcQGUfHrz-ela1C1YACAEIylimr59rk,6701
|
|
7
7
|
ren_ui/project.py,sha256=9H-d_2km-gF6CMUk4dUJkLNDHp_Mpgie-TKkZ4XqX8U,9976
|
|
8
8
|
ren_ui/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
ren_ui/resources.py,sha256=9DL2ioFogrd_Fqn4mqzUi2_gTS5qE_at4CR7qMy-HuM,1208
|
|
10
10
|
ren_ui/system.py,sha256=CyXttiKEd7Yns2ziwmQYWGvBszpflB-NJLndwn9Amdw,2605
|
|
11
|
-
ren_ui/widgets.py,sha256=
|
|
11
|
+
ren_ui/widgets.py,sha256=pfJIv5oyY0Ucgzf_7zFiC-MkADuC7zLncBq0l0gTrjw,12808
|
|
12
12
|
ren_ui/native/bridge.cpp,sha256=px_hwpqsHJoCkjaBX6YZShjnH8TEy6_j5aJZD0P3hpo,25738
|
|
13
13
|
ren_ui/native/icon.cpp,sha256=SD8zUQiI7umRVhR1QZxjZpE_PKmomCVlIkRaE60xBRo,3180
|
|
14
14
|
ren_ui/native/launcher.cpp,sha256=BTx4AZeCwb1grZNlqKTlo5FJ0kaM3nEmCfQH8S74LbM,2371
|
|
15
|
-
ren_ui_python-0.
|
|
16
|
-
ren_ui_python-0.
|
|
17
|
-
ren_ui_python-0.
|
|
18
|
-
ren_ui_python-0.
|
|
19
|
-
ren_ui_python-0.
|
|
20
|
-
ren_ui_python-0.
|
|
15
|
+
ren_ui_python-0.2.0.dist-info/licenses/LICENSE,sha256=UalO_7O5rJWiGc4bYF0OH8J9Qhs5dfHtxWFulh_BKjQ,1083
|
|
16
|
+
ren_ui_python-0.2.0.dist-info/METADATA,sha256=NOddxG9OnIrRvvPUlGQpCKY-JDpj35EOC-QAReZyfWY,3119
|
|
17
|
+
ren_ui_python-0.2.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
18
|
+
ren_ui_python-0.2.0.dist-info/entry_points.txt,sha256=LOkVNW7u9QKiSoTpTn4D-PBn7SuVlws5Gs9wHCPZM2g,65
|
|
19
|
+
ren_ui_python-0.2.0.dist-info/top_level.txt,sha256=9NpBXuu4pH2npjBvFuTgZhg-QhPeshZxZByoj3WUDSg,7
|
|
20
|
+
ren_ui_python-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|