quantumgui 1.0.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.
- quantumgui/__init__.py +9 -0
- quantumgui/__main__.py +6 -0
- quantumgui/cli.py +341 -0
- quantumgui/core/__init__.py +39 -0
- quantumgui/core/animation.py +221 -0
- quantumgui/core/audit.py +323 -0
- quantumgui/core/context.py +54 -0
- quantumgui/core/data_source.py +426 -0
- quantumgui/core/draw.py +428 -0
- quantumgui/core/enterprise.py +402 -0
- quantumgui/core/enterprise_app.py +419 -0
- quantumgui/core/events.py +34 -0
- quantumgui/core/geometry.py +108 -0
- quantumgui/core/native_dialogs.py +276 -0
- quantumgui/core/pdf_report.py +390 -0
- quantumgui/core/rules.py +284 -0
- quantumgui/core/state.py +42 -0
- quantumgui/core/task_runner.py +181 -0
- quantumgui/core/widget.py +498 -0
- quantumgui/core/window.py +920 -0
- quantumgui/core/xlsx_export.py +145 -0
- quantumgui/py.typed +0 -0
- quantumgui/theme/__init__.py +32 -0
- quantumgui/theme/hct.py +191 -0
- quantumgui/theme/theme.py +93 -0
- quantumgui/theme/tokens.py +423 -0
- quantumgui/ui.py +2142 -0
- quantumgui/widgets/__init__.py +168 -0
- quantumgui/widgets/advanced.py +499 -0
- quantumgui/widgets/button.py +224 -0
- quantumgui/widgets/charts.py +625 -0
- quantumgui/widgets/charts_bi.py +528 -0
- quantumgui/widgets/charts_extra.py +430 -0
- quantumgui/widgets/charts_pro.py +568 -0
- quantumgui/widgets/checkbox.py +199 -0
- quantumgui/widgets/chip.py +219 -0
- quantumgui/widgets/containers.py +321 -0
- quantumgui/widgets/data_controls.py +487 -0
- quantumgui/widgets/data_grid.py +956 -0
- quantumgui/widgets/data_table.py +551 -0
- quantumgui/widgets/date_picker.py +407 -0
- quantumgui/widgets/display_media.py +372 -0
- quantumgui/widgets/display_pro.py +407 -0
- quantumgui/widgets/drawer.py +252 -0
- quantumgui/widgets/enterprise_controls.py +934 -0
- quantumgui/widgets/fab.py +261 -0
- quantumgui/widgets/forms_pro.py +703 -0
- quantumgui/widgets/forms_pro_media.py +587 -0
- quantumgui/widgets/inputs.py +870 -0
- quantumgui/widgets/layout_pro.py +162 -0
- quantumgui/widgets/list_view.py +307 -0
- quantumgui/widgets/masked_input.py +131 -0
- quantumgui/widgets/master_detail.py +155 -0
- quantumgui/widgets/navigation.py +382 -0
- quantumgui/widgets/overlays.py +355 -0
- quantumgui/widgets/productivity.py +500 -0
- quantumgui/widgets/productivity_boards.py +544 -0
- quantumgui/widgets/radio.py +209 -0
- quantumgui/widgets/scroll_view.py +129 -0
- quantumgui/widgets/select.py +373 -0
- quantumgui/widgets/sheets.py +249 -0
- quantumgui/widgets/slider.py +209 -0
- quantumgui/widgets/switch.py +196 -0
- quantumgui/widgets/tabs.py +175 -0
- quantumgui/widgets/text.py +101 -0
- quantumgui/widgets/text_field.py +490 -0
- quantumgui/widgets/time_picker.py +499 -0
- quantumgui-1.0.0.dist-info/METADATA +137 -0
- quantumgui-1.0.0.dist-info/RECORD +73 -0
- quantumgui-1.0.0.dist-info/WHEEL +5 -0
- quantumgui-1.0.0.dist-info/entry_points.txt +2 -0
- quantumgui-1.0.0.dist-info/licenses/LICENSE +32 -0
- quantumgui-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
"""Material Design 3 TimePicker with interactive Analog Clock Dial Overlay."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
from datetime import time as dt_time
|
|
7
|
+
from typing import Callable, Literal
|
|
8
|
+
|
|
9
|
+
import skia
|
|
10
|
+
|
|
11
|
+
from ..core.animation import AnimatedValue
|
|
12
|
+
from ..core.draw import (
|
|
13
|
+
draw_elevation_shadow,
|
|
14
|
+
draw_icon,
|
|
15
|
+
draw_text_centered_y,
|
|
16
|
+
font_for_style,
|
|
17
|
+
get_font,
|
|
18
|
+
make_rrect,
|
|
19
|
+
make_rrect_spec,
|
|
20
|
+
measure_text,
|
|
21
|
+
resolve_color,
|
|
22
|
+
)
|
|
23
|
+
from ..core.events import MouseEvent
|
|
24
|
+
from ..core.geometry import Constraints, Rect, Size
|
|
25
|
+
from ..core.state import State
|
|
26
|
+
from ..core.widget import Widget
|
|
27
|
+
from ..theme import Theme
|
|
28
|
+
|
|
29
|
+
TimePickerVariant = Literal["outlined", "filled"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class _TimePickerOverlay(Widget):
|
|
33
|
+
"""Official Material Design 3 Time Picker Dial Popup (24h dual-ring or 12h AM/PM)."""
|
|
34
|
+
|
|
35
|
+
interactive = True
|
|
36
|
+
auto_attach = False
|
|
37
|
+
cursor = "pointer"
|
|
38
|
+
|
|
39
|
+
POPUP_W = 328.0
|
|
40
|
+
POPUP_H = 444.0
|
|
41
|
+
DIAL_R = 104.0
|
|
42
|
+
|
|
43
|
+
def __init__(self, owner: TimePicker) -> None:
|
|
44
|
+
super().__init__()
|
|
45
|
+
self.owner = owner
|
|
46
|
+
ref = owner.value or dt_time(12, 0)
|
|
47
|
+
self.hour: int = ref.hour
|
|
48
|
+
self.minute: int = ref.minute
|
|
49
|
+
self.mode: Literal["hour", "minute"] = "hour"
|
|
50
|
+
self._dragging_dial = False
|
|
51
|
+
|
|
52
|
+
self._popup_rect = Rect(0.0, 0.0, 0.0, 0.0)
|
|
53
|
+
self._hour_rect = Rect(0.0, 0.0, 0.0, 0.0)
|
|
54
|
+
self._min_rect = Rect(0.0, 0.0, 0.0, 0.0)
|
|
55
|
+
self._am_rect = Rect(0.0, 0.0, 0.0, 0.0)
|
|
56
|
+
self._pm_rect = Rect(0.0, 0.0, 0.0, 0.0)
|
|
57
|
+
self._dial_cx = 0.0
|
|
58
|
+
self._dial_cy = 0.0
|
|
59
|
+
self._cancel_rect = Rect(0.0, 0.0, 0.0, 0.0)
|
|
60
|
+
self._ok_rect = Rect(0.0, 0.0, 0.0, 0.0)
|
|
61
|
+
|
|
62
|
+
def layout(self, rect: Rect, theme: Theme) -> None:
|
|
63
|
+
self.rect = rect
|
|
64
|
+
anchor = self.owner.rect
|
|
65
|
+
x = max(8.0, min(rect.width - self.POPUP_W - 8.0, anchor.x))
|
|
66
|
+
y = anchor.y + self.owner.BOX_HEIGHT + 6.0
|
|
67
|
+
if y + self.POPUP_H > rect.height - 8.0:
|
|
68
|
+
y = max(8.0, (rect.height - self.POPUP_H) * 0.5)
|
|
69
|
+
self._popup_rect = Rect(x, y, self.POPUP_W, self.POPUP_H)
|
|
70
|
+
|
|
71
|
+
# Digital header tiles
|
|
72
|
+
tile_w, tile_h = 84.0, 64.0
|
|
73
|
+
if self.owner.use_24h:
|
|
74
|
+
hx = x + (self.POPUP_W - (tile_w * 2 + 20.0)) * 0.5
|
|
75
|
+
else:
|
|
76
|
+
hx = x + 24.0
|
|
77
|
+
hy = y + 48.0
|
|
78
|
+
self._hour_rect = Rect(hx, hy, tile_w, tile_h)
|
|
79
|
+
self._min_rect = Rect(hx + tile_w + 20.0, hy, tile_w, tile_h)
|
|
80
|
+
self._am_rect = Rect(self._min_rect.right + 12.0, hy, 52.0, tile_h * 0.5)
|
|
81
|
+
self._pm_rect = Rect(self._min_rect.right + 12.0, hy + tile_h * 0.5, 52.0, tile_h * 0.5)
|
|
82
|
+
|
|
83
|
+
self._dial_cx = x + self.POPUP_W * 0.5
|
|
84
|
+
self._dial_cy = y + 244.0
|
|
85
|
+
|
|
86
|
+
self._ok_rect = Rect(x + self.POPUP_W - 92.0, y + self.POPUP_H - 52.0, 76.0, 36.0)
|
|
87
|
+
self._cancel_rect = Rect(self._ok_rect.x - 92.0, y + self.POPUP_H - 52.0, 84.0, 36.0)
|
|
88
|
+
|
|
89
|
+
def hit_test(self, x: float, y: float) -> Widget | None:
|
|
90
|
+
return self if self._popup_rect.contains(x, y) else None
|
|
91
|
+
|
|
92
|
+
def _update_from_dial(self, px: float, py: float) -> None:
|
|
93
|
+
dx = px - self._dial_cx
|
|
94
|
+
dy = py - self._dial_cy
|
|
95
|
+
dist = math.hypot(dx, dy)
|
|
96
|
+
# Angle clockwise from 12 o'clock in [0, 2*pi)
|
|
97
|
+
ang = (math.atan2(dx, -dy)) % (2.0 * math.pi)
|
|
98
|
+
|
|
99
|
+
if self.mode == "hour":
|
|
100
|
+
step = int(round(ang / (2.0 * math.pi / 12.0))) % 12
|
|
101
|
+
if self.owner.use_24h:
|
|
102
|
+
inner = dist < (self.DIAL_R * 0.67)
|
|
103
|
+
if inner:
|
|
104
|
+
self.hour = 0 if step == 0 else step + 12
|
|
105
|
+
else:
|
|
106
|
+
self.hour = 12 if step == 0 else step
|
|
107
|
+
else:
|
|
108
|
+
is_pm = self.hour >= 12
|
|
109
|
+
h12 = 12 if step == 0 else step
|
|
110
|
+
if is_pm:
|
|
111
|
+
self.hour = 12 if h12 == 12 else h12 + 12
|
|
112
|
+
else:
|
|
113
|
+
self.hour = 0 if h12 == 12 else h12
|
|
114
|
+
else:
|
|
115
|
+
self.minute = int(round(ang / (2.0 * math.pi / 60.0))) % 60
|
|
116
|
+
self.invalidate()
|
|
117
|
+
|
|
118
|
+
def on_mouse_down(self, event: MouseEvent) -> None:
|
|
119
|
+
super().on_mouse_down(event)
|
|
120
|
+
if math.hypot(event.x - self._dial_cx, event.y - self._dial_cy) <= self.DIAL_R + 8.0:
|
|
121
|
+
self._dragging_dial = True
|
|
122
|
+
self._update_from_dial(event.x, event.y)
|
|
123
|
+
|
|
124
|
+
def on_mouse_move(self, event: MouseEvent) -> None:
|
|
125
|
+
if self._dragging_dial:
|
|
126
|
+
self._update_from_dial(event.x, event.y)
|
|
127
|
+
|
|
128
|
+
def on_mouse_up(self, event: MouseEvent) -> None:
|
|
129
|
+
was_pressed = self.pressed
|
|
130
|
+
was_dragging = self._dragging_dial
|
|
131
|
+
self._dragging_dial = False
|
|
132
|
+
super().on_mouse_up(event)
|
|
133
|
+
if not was_pressed:
|
|
134
|
+
return
|
|
135
|
+
|
|
136
|
+
if was_dragging:
|
|
137
|
+
if self.mode == "hour":
|
|
138
|
+
self.mode = "minute"
|
|
139
|
+
self.invalidate()
|
|
140
|
+
return
|
|
141
|
+
|
|
142
|
+
if self._hour_rect.contains(event.x, event.y):
|
|
143
|
+
self.mode = "hour"
|
|
144
|
+
self.invalidate()
|
|
145
|
+
elif self._min_rect.contains(event.x, event.y):
|
|
146
|
+
self.mode = "minute"
|
|
147
|
+
self.invalidate()
|
|
148
|
+
elif not self.owner.use_24h and self._am_rect.contains(event.x, event.y):
|
|
149
|
+
if self.hour >= 12:
|
|
150
|
+
self.hour -= 12
|
|
151
|
+
self.invalidate()
|
|
152
|
+
elif not self.owner.use_24h and self._pm_rect.contains(event.x, event.y):
|
|
153
|
+
if self.hour < 12:
|
|
154
|
+
self.hour += 12
|
|
155
|
+
self.invalidate()
|
|
156
|
+
elif self._cancel_rect.contains(event.x, event.y):
|
|
157
|
+
self.owner.close_picker()
|
|
158
|
+
elif self._ok_rect.contains(event.x, event.y):
|
|
159
|
+
self.owner._pick_time(dt_time(self.hour, self.minute))
|
|
160
|
+
self.owner.close_picker()
|
|
161
|
+
|
|
162
|
+
def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
|
|
163
|
+
c = theme.colors
|
|
164
|
+
pr = self._popup_rect
|
|
165
|
+
radius = theme.shape.extra_large
|
|
166
|
+
|
|
167
|
+
draw_elevation_shadow(canvas, pr, radius, 3, c.shadow)
|
|
168
|
+
canvas.drawRRect(make_rrect(pr, radius), skia.Paint(AntiAlias=True, Color=c.surface_container_high.to_skia()))
|
|
169
|
+
|
|
170
|
+
# Header caption
|
|
171
|
+
cap_font = font_for_style(theme.font_family, theme.typography.label_medium)
|
|
172
|
+
draw_text_centered_y(canvas, "Seleccionar hora", pr.x + 24.0, pr.y + 26.0, cap_font, c.on_surface_variant)
|
|
173
|
+
|
|
174
|
+
# Hour & Minute tiles
|
|
175
|
+
disp_h = self.hour if self.owner.use_24h else ((self.hour % 12) or 12)
|
|
176
|
+
num_font = font_for_style(theme.font_family, theme.typography.display_small)
|
|
177
|
+
|
|
178
|
+
for rect, val_str, active in (
|
|
179
|
+
(self._hour_rect, f"{disp_h:02d}", self.mode == "hour"),
|
|
180
|
+
(self._min_rect, f"{self.minute:02d}", self.mode == "minute"),
|
|
181
|
+
):
|
|
182
|
+
bg = c.primary_container if active else c.surface_container_highest
|
|
183
|
+
fg = c.on_primary_container if active else c.on_surface
|
|
184
|
+
canvas.drawRRect(make_rrect(rect, theme.shape.small), skia.Paint(AntiAlias=True, Color=bg.to_skia()))
|
|
185
|
+
tw = measure_text(num_font, val_str)
|
|
186
|
+
draw_text_centered_y(canvas, val_str, rect.center_x - tw * 0.5, rect.center_y, num_font, fg)
|
|
187
|
+
|
|
188
|
+
# Colon ":"
|
|
189
|
+
colon_x = (self._hour_rect.right + self._min_rect.x) * 0.5
|
|
190
|
+
cw = measure_text(num_font, ":")
|
|
191
|
+
draw_text_centered_y(canvas, ":", colon_x - cw * 0.5, self._hour_rect.center_y - 2.0, num_font, c.on_surface)
|
|
192
|
+
|
|
193
|
+
# AM / PM toggle (12h mode)
|
|
194
|
+
if not self.owner.use_24h:
|
|
195
|
+
is_pm = self.hour >= 12
|
|
196
|
+
ampm_font = font_for_style(theme.font_family, theme.typography.title_small)
|
|
197
|
+
for rect, txt, sel in (
|
|
198
|
+
(self._am_rect, "AM", not is_pm),
|
|
199
|
+
(self._pm_rect, "PM", is_pm),
|
|
200
|
+
):
|
|
201
|
+
bg = c.tertiary_container if sel else c.surface_container_highest
|
|
202
|
+
fg = c.on_tertiary_container if sel else c.on_surface_variant
|
|
203
|
+
canvas.drawRRect(make_rrect(rect, 6.0), skia.Paint(AntiAlias=True, Color=bg.to_skia()))
|
|
204
|
+
tw = measure_text(ampm_font, txt)
|
|
205
|
+
draw_text_centered_y(canvas, txt, rect.center_x - tw * 0.5, rect.center_y, ampm_font, fg)
|
|
206
|
+
|
|
207
|
+
# Analog Clock Dial
|
|
208
|
+
cx, cy = self._dial_cx, self._dial_cy
|
|
209
|
+
canvas.drawCircle(cx, cy, self.DIAL_R, skia.Paint(AntiAlias=True, Color=c.surface_container_highest.to_skia()))
|
|
210
|
+
|
|
211
|
+
# Compute selected hand position
|
|
212
|
+
outer_r = self.DIAL_R - 22.0
|
|
213
|
+
inner_r = self.DIAL_R - 52.0
|
|
214
|
+
if self.mode == "hour":
|
|
215
|
+
if self.owner.use_24h:
|
|
216
|
+
is_inner = self.hour == 0 or self.hour >= 13
|
|
217
|
+
idx = (self.hour % 12)
|
|
218
|
+
sel_r = inner_r if is_inner else outer_r
|
|
219
|
+
else:
|
|
220
|
+
idx = (self.hour % 12)
|
|
221
|
+
sel_r = outer_r
|
|
222
|
+
ang = idx * (2.0 * math.pi / 12.0)
|
|
223
|
+
else:
|
|
224
|
+
sel_r = outer_r
|
|
225
|
+
ang = self.minute * (2.0 * math.pi / 60.0)
|
|
226
|
+
|
|
227
|
+
hx = cx + math.sin(ang) * sel_r
|
|
228
|
+
hy = cy - math.cos(ang) * sel_r
|
|
229
|
+
|
|
230
|
+
# Clock hand & selector circle
|
|
231
|
+
canvas.drawLine(cx, cy, hx, hy, skia.Paint(AntiAlias=True, Color=c.primary.to_skia(), StrokeWidth=2.0))
|
|
232
|
+
canvas.drawCircle(cx, cy, 4.0, skia.Paint(AntiAlias=True, Color=c.primary.to_skia()))
|
|
233
|
+
canvas.drawCircle(hx, hy, 18.0, skia.Paint(AntiAlias=True, Color=c.primary.to_skia()))
|
|
234
|
+
|
|
235
|
+
# Dial numbers
|
|
236
|
+
dial_font = font_for_style(theme.font_family, theme.typography.body_medium)
|
|
237
|
+
inner_font = font_for_style(theme.font_family, theme.typography.body_small)
|
|
238
|
+
if self.mode == "hour":
|
|
239
|
+
for i in range(12):
|
|
240
|
+
a = i * (2.0 * math.pi / 12.0)
|
|
241
|
+
nx = cx + math.sin(a) * outer_r
|
|
242
|
+
ny = cy - math.cos(a) * outer_r
|
|
243
|
+
val = 12 if i == 0 else i
|
|
244
|
+
is_sel = (self.hour == val) if self.owner.use_24h else (((self.hour % 12) or 12) == val)
|
|
245
|
+
s = str(val)
|
|
246
|
+
sw = measure_text(dial_font, s)
|
|
247
|
+
draw_text_centered_y(canvas, s, nx - sw * 0.5, ny, dial_font, c.on_primary if is_sel else c.on_surface)
|
|
248
|
+
|
|
249
|
+
if self.owner.use_24h:
|
|
250
|
+
ix = cx + math.sin(a) * inner_r
|
|
251
|
+
iy = cy - math.cos(a) * inner_r
|
|
252
|
+
ival = 0 if i == 0 else i + 12
|
|
253
|
+
isel = self.hour == ival
|
|
254
|
+
s2 = f"{ival:02d}"
|
|
255
|
+
sw2 = measure_text(inner_font, s2)
|
|
256
|
+
draw_text_centered_y(
|
|
257
|
+
canvas, s2, ix - sw2 * 0.5, iy, inner_font, c.on_primary if isel else c.on_surface_variant
|
|
258
|
+
)
|
|
259
|
+
else:
|
|
260
|
+
for i in range(12):
|
|
261
|
+
a = i * (2.0 * math.pi / 12.0)
|
|
262
|
+
nx = cx + math.sin(a) * outer_r
|
|
263
|
+
ny = cy - math.cos(a) * outer_r
|
|
264
|
+
mval = i * 5
|
|
265
|
+
is_sel = self.minute == mval
|
|
266
|
+
s = f"{mval:02d}"
|
|
267
|
+
sw = measure_text(dial_font, s)
|
|
268
|
+
draw_text_centered_y(canvas, s, nx - sw * 0.5, ny, dial_font, c.on_primary if is_sel else c.on_surface)
|
|
269
|
+
|
|
270
|
+
# Action buttons (Cancelar / Aceptar)
|
|
271
|
+
btn_font = font_for_style(theme.font_family, theme.typography.label_large)
|
|
272
|
+
for rect, txt in ((self._cancel_rect, "Cancelar"), (self._ok_rect, "Aceptar")):
|
|
273
|
+
tw = measure_text(btn_font, txt)
|
|
274
|
+
draw_text_centered_y(canvas, txt, rect.center_x - tw * 0.5, rect.center_y, btn_font, c.primary)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class TimePicker(Widget):
|
|
278
|
+
"""Official Material Design 3 TimePicker (`outlined` or `filled` trigger + Clock Dial)."""
|
|
279
|
+
|
|
280
|
+
interactive = True
|
|
281
|
+
focusable = True
|
|
282
|
+
manages_own_box = True
|
|
283
|
+
cursor = "pointer"
|
|
284
|
+
|
|
285
|
+
BOX_HEIGHT = 56.0
|
|
286
|
+
SUPPORTING_HEIGHT = 20.0
|
|
287
|
+
|
|
288
|
+
def __init__(
|
|
289
|
+
self,
|
|
290
|
+
label: str = "Hora",
|
|
291
|
+
*,
|
|
292
|
+
value: dt_time | None = None,
|
|
293
|
+
use_24h: bool = True,
|
|
294
|
+
variant: TimePickerVariant = "outlined",
|
|
295
|
+
supporting_text: str | None = None,
|
|
296
|
+
error_text: str | None = None,
|
|
297
|
+
disabled: bool = False,
|
|
298
|
+
bind: State[dt_time | None] | None = None,
|
|
299
|
+
on_change: Callable[[dt_time], None] | None = None,
|
|
300
|
+
) -> None:
|
|
301
|
+
super().__init__()
|
|
302
|
+
self.label = label
|
|
303
|
+
self.use_24h = use_24h
|
|
304
|
+
self.variant: TimePickerVariant = variant
|
|
305
|
+
self._bind = bind
|
|
306
|
+
self._value: dt_time | None = bind.value if bind is not None else value
|
|
307
|
+
self.supporting_text = supporting_text
|
|
308
|
+
self._error_text = error_text
|
|
309
|
+
self.disabled = disabled
|
|
310
|
+
self.on_change = on_change
|
|
311
|
+
|
|
312
|
+
self._open = False
|
|
313
|
+
self._overlay: _TimePickerOverlay | None = None
|
|
314
|
+
self._float_anim = AnimatedValue(1.0 if self._value is not None else 0.0, duration=0.16)
|
|
315
|
+
|
|
316
|
+
if bind is not None:
|
|
317
|
+
bind.subscribe(self._on_bound_change)
|
|
318
|
+
|
|
319
|
+
def _on_bound_change(self, new_val: dt_time | None) -> None:
|
|
320
|
+
if new_val != self._value:
|
|
321
|
+
self._value = new_val
|
|
322
|
+
self._float_anim.animate_to(1.0 if (self._value is not None or self._open) else 0.0)
|
|
323
|
+
self.invalidate()
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def value(self) -> dt_time | None:
|
|
327
|
+
return self._value
|
|
328
|
+
|
|
329
|
+
@value.setter
|
|
330
|
+
def value(self, val: dt_time | None) -> None:
|
|
331
|
+
if val != self._value:
|
|
332
|
+
self._value = val
|
|
333
|
+
self._float_anim.animate_to(1.0 if (self._value is not None or self._open) else 0.0)
|
|
334
|
+
if self._bind is not None and self._bind.value != val:
|
|
335
|
+
self._bind.value = val
|
|
336
|
+
self.invalidate()
|
|
337
|
+
|
|
338
|
+
def _format_time(self) -> str:
|
|
339
|
+
if self._value is None:
|
|
340
|
+
return ""
|
|
341
|
+
if self.use_24h:
|
|
342
|
+
return f"{self._value.hour:02d}:{self._value.minute:02d}"
|
|
343
|
+
h12 = (self._value.hour % 12) or 12
|
|
344
|
+
suffix = "PM" if self._value.hour >= 12 else "AM"
|
|
345
|
+
return f"{h12:02d}:{self._value.minute:02d} {suffix}"
|
|
346
|
+
|
|
347
|
+
def _pick_time(self, picked: dt_time) -> None:
|
|
348
|
+
self.value = picked
|
|
349
|
+
if self.on_change is not None:
|
|
350
|
+
self.on_change(picked)
|
|
351
|
+
|
|
352
|
+
def open_picker(self) -> None:
|
|
353
|
+
if self.disabled or self.window is None:
|
|
354
|
+
return
|
|
355
|
+
self._open = True
|
|
356
|
+
self._float_anim.animate_to(1.0)
|
|
357
|
+
self._overlay = _TimePickerOverlay(self)
|
|
358
|
+
self.window.open_overlay(self._overlay)
|
|
359
|
+
self.invalidate()
|
|
360
|
+
|
|
361
|
+
def close_picker(self) -> None:
|
|
362
|
+
self._open = False
|
|
363
|
+
if self._overlay is not None and self.window is not None:
|
|
364
|
+
self.window.close_overlay(self._overlay)
|
|
365
|
+
self._overlay = None
|
|
366
|
+
self._float_anim.animate_to(1.0 if self._value is not None else 0.0)
|
|
367
|
+
self.invalidate()
|
|
368
|
+
|
|
369
|
+
def _has_footer(self) -> bool:
|
|
370
|
+
return bool(self._error_text or self.supporting_text)
|
|
371
|
+
|
|
372
|
+
def _measure_content(self, constraints: Constraints, theme: Theme) -> Size:
|
|
373
|
+
h = self.BOX_HEIGHT + (self.SUPPORTING_HEIGHT if self._has_footer() else 0.0)
|
|
374
|
+
w = 220.0 if constraints.max_width == float("inf") else min(220.0, constraints.max_width)
|
|
375
|
+
return Size(w, h)
|
|
376
|
+
|
|
377
|
+
def tick(self, now: float) -> bool:
|
|
378
|
+
if self._open and self.window is not None and self._overlay not in self.window._overlays:
|
|
379
|
+
self._open = False
|
|
380
|
+
self._overlay = None
|
|
381
|
+
self._float_anim.animate_to(1.0 if self._value is not None else 0.0)
|
|
382
|
+
return self._float_anim.update(now)
|
|
383
|
+
|
|
384
|
+
def on_mouse_up(self, event: MouseEvent) -> None:
|
|
385
|
+
was_pressed = self.pressed
|
|
386
|
+
super().on_mouse_up(event)
|
|
387
|
+
if self.disabled or not was_pressed or not self.rect.contains(event.x, event.y):
|
|
388
|
+
return
|
|
389
|
+
if self._open:
|
|
390
|
+
self.close_picker()
|
|
391
|
+
else:
|
|
392
|
+
self.open_picker()
|
|
393
|
+
|
|
394
|
+
def _paint_self(self, canvas: skia.Canvas, theme: Theme, now: float) -> None:
|
|
395
|
+
c = theme.colors
|
|
396
|
+
is_error = bool(self._error_text)
|
|
397
|
+
active = self._open or self.focused
|
|
398
|
+
box = Rect(self.rect.x, self.rect.y, self.rect.width, self.BOX_HEIGHT)
|
|
399
|
+
f_t = self._float_anim.current
|
|
400
|
+
|
|
401
|
+
if self.disabled:
|
|
402
|
+
outline_color = c.on_surface.with_alpha(0.12)
|
|
403
|
+
label_color = c.on_surface.with_alpha(0.38)
|
|
404
|
+
text_color = c.on_surface.with_alpha(0.38)
|
|
405
|
+
icon_color = c.on_surface.with_alpha(0.38)
|
|
406
|
+
elif is_error:
|
|
407
|
+
outline_color = c.error
|
|
408
|
+
label_color = c.error
|
|
409
|
+
text_color = c.on_surface
|
|
410
|
+
icon_color = c.error
|
|
411
|
+
elif active:
|
|
412
|
+
outline_color = c.primary
|
|
413
|
+
label_color = c.primary
|
|
414
|
+
text_color = c.on_surface
|
|
415
|
+
icon_color = c.primary
|
|
416
|
+
else:
|
|
417
|
+
outline_color = c.on_surface if self.hovered else c.outline
|
|
418
|
+
label_color = c.on_surface_variant
|
|
419
|
+
text_color = c.on_surface
|
|
420
|
+
icon_color = c.on_surface_variant
|
|
421
|
+
|
|
422
|
+
if not self.disabled and not is_error and not active and self._border_color_override is not None:
|
|
423
|
+
outline_color = resolve_color(self._border_color_override, theme, outline_color) or outline_color
|
|
424
|
+
if not self.disabled and self._fg_override is not None:
|
|
425
|
+
text_color = resolve_color(self._fg_override, theme, text_color) or text_color
|
|
426
|
+
border_w = self._border_width_override if self._border_width_override is not None else (2.0 if active else 1.0)
|
|
427
|
+
label_size = 16.0 - 4.0 * f_t
|
|
428
|
+
label_font = get_font(theme.font_family, label_size, 500 if active else 400)
|
|
429
|
+
label_w = measure_text(label_font, self.label)
|
|
430
|
+
|
|
431
|
+
if self.variant == "filled":
|
|
432
|
+
if self._elevation_override:
|
|
433
|
+
sh = resolve_color(self._shadow_color_override, theme, c.shadow)
|
|
434
|
+
assert sh is not None
|
|
435
|
+
draw_elevation_shadow(canvas, box, 4.0, self._elevation_override, sh)
|
|
436
|
+
rrect = skia.RRect()
|
|
437
|
+
rrect.setRectRadii(
|
|
438
|
+
skia.Rect.MakeXYWH(box.x, box.y, box.width, box.height),
|
|
439
|
+
[(4.0, 4.0), (4.0, 4.0), (0.0, 0.0), (0.0, 0.0)],
|
|
440
|
+
)
|
|
441
|
+
bg = resolve_color(self._bg_override, theme, c.surface_container_highest) or c.surface_container_highest
|
|
442
|
+
canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Color=bg.to_skia()))
|
|
443
|
+
canvas.drawLine(
|
|
444
|
+
box.x,
|
|
445
|
+
box.bottom - border_w * 0.5,
|
|
446
|
+
box.right,
|
|
447
|
+
box.bottom - border_w * 0.5,
|
|
448
|
+
skia.Paint(AntiAlias=True, Color=outline_color.to_skia(), StrokeWidth=border_w),
|
|
449
|
+
)
|
|
450
|
+
label_cy = box.center_y * (1.0 - f_t) + (box.y + 15.0) * f_t
|
|
451
|
+
text_cy = box.y + 37.0
|
|
452
|
+
else:
|
|
453
|
+
rad_spec = self._shape_override if self._shape_override is not None else "extra_small"
|
|
454
|
+
rad_num = rad_spec[0] if isinstance(rad_spec, tuple) else theme.shape.resolve(rad_spec)
|
|
455
|
+
if self._elevation_override:
|
|
456
|
+
sh = resolve_color(self._shadow_color_override, theme, c.shadow)
|
|
457
|
+
assert sh is not None
|
|
458
|
+
draw_elevation_shadow(canvas, box, rad_num, self._elevation_override, sh)
|
|
459
|
+
rrect = make_rrect_spec(box, rad_spec, theme)
|
|
460
|
+
if self._bg_override is not None:
|
|
461
|
+
bg = resolve_color(self._bg_override, theme)
|
|
462
|
+
if bg is not None:
|
|
463
|
+
canvas.drawRRect(rrect, skia.Paint(AntiAlias=True, Color=bg.to_skia()))
|
|
464
|
+
canvas.save()
|
|
465
|
+
if f_t > 0.05 and self.label:
|
|
466
|
+
notch_left = box.x + 12.0
|
|
467
|
+
notch_right = notch_left + label_w + 8.0
|
|
468
|
+
canvas.clipRect(
|
|
469
|
+
skia.Rect.MakeXYWH(notch_left, box.y - 4.0, notch_right - notch_left, 10.0),
|
|
470
|
+
skia.ClipOp.kDifference,
|
|
471
|
+
)
|
|
472
|
+
canvas.drawRRect(
|
|
473
|
+
rrect,
|
|
474
|
+
skia.Paint(
|
|
475
|
+
AntiAlias=True,
|
|
476
|
+
Color=outline_color.to_skia(),
|
|
477
|
+
Style=skia.Paint.kStroke_Style,
|
|
478
|
+
StrokeWidth=border_w,
|
|
479
|
+
),
|
|
480
|
+
)
|
|
481
|
+
canvas.restore()
|
|
482
|
+
label_cy = box.center_y * (1.0 - f_t) + box.y * f_t
|
|
483
|
+
text_cy = box.center_y
|
|
484
|
+
|
|
485
|
+
draw_icon(canvas, "clock", box.right - 24.0, box.center_y, 18.0, icon_color)
|
|
486
|
+
if self.label:
|
|
487
|
+
draw_text_centered_y(canvas, self.label, box.x + 16.0, label_cy, label_font, label_color)
|
|
488
|
+
|
|
489
|
+
formatted = self._format_time()
|
|
490
|
+
if formatted:
|
|
491
|
+
body_font = font_for_style(theme.font_family, theme.typography.body_large)
|
|
492
|
+
draw_text_centered_y(canvas, formatted, box.x + 16.0, text_cy, body_font, text_color)
|
|
493
|
+
|
|
494
|
+
if self._has_footer():
|
|
495
|
+
footer_font = font_for_style(theme.font_family, theme.typography.body_small)
|
|
496
|
+
msg = self._error_text if is_error else (self.supporting_text or "")
|
|
497
|
+
draw_text_centered_y(
|
|
498
|
+
canvas, msg, box.x + 16.0, box.bottom + 12.0, footer_font, c.error if is_error else c.on_surface_variant
|
|
499
|
+
)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quantumgui
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Native GPU-accelerated Python GUI library built 100% on Material Design 3 standards.
|
|
5
|
+
Author: QuantumGUI Contributors
|
|
6
|
+
License: QuantumGUI Community & Commercial License v1.0
|
|
7
|
+
Copyright (c) 2026 QuantumGUI Authors. All rights reserved.
|
|
8
|
+
|
|
9
|
+
1. GRANT OF COMMUNITY LICENSE (FREE TIER)
|
|
10
|
+
Permission is hereby granted, free of charge, to use, copy, modify, and distribute
|
|
11
|
+
applications built with QuantumGUI ("the Software") strictly under the following
|
|
12
|
+
conditions:
|
|
13
|
+
(a) Personal, educational, academic, or non-profit open-source use; OR
|
|
14
|
+
(b) Commercial use by an individual, freelancer, or organization whose total
|
|
15
|
+
annual gross revenue (including funding or project revenue) is strictly
|
|
16
|
+
less than USD $25,000 per year.
|
|
17
|
+
|
|
18
|
+
2. COMMERCIAL LICENSE REQUIREMENT
|
|
19
|
+
Any individual, organization, or commercial project with annual gross revenue equal
|
|
20
|
+
to or greater than USD $25,000 MUST obtain a valid QuantumGUI Commercial License
|
|
21
|
+
before using the Software in production or distributing applications built with it.
|
|
22
|
+
Companies of any size may evaluate the Software internally for up to 30 days.
|
|
23
|
+
|
|
24
|
+
3. RESTRICTIONS
|
|
25
|
+
Under the Community License, you may NOT:
|
|
26
|
+
(a) Redistribute, repackage, or sell the Software itself (in whole or in part)
|
|
27
|
+
as a competing GUI library, UI component suite, or visual RAD/IDE tool;
|
|
28
|
+
(b) Remove or obscure copyright or license notices included in the Software.
|
|
29
|
+
|
|
30
|
+
4. DISCLAIMER OF WARRANTY
|
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
32
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
33
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
34
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM THE USE
|
|
35
|
+
OF THE SOFTWARE.
|
|
36
|
+
|
|
37
|
+
For commercial licensing inquiries, contact the QuantumGUI maintainers.
|
|
38
|
+
|
|
39
|
+
Project-URL: Homepage, https://pablometal1.github.io/quantumgui-web/
|
|
40
|
+
Project-URL: Documentation, https://pablometal1.github.io/quantumgui-web/docs.html
|
|
41
|
+
Project-URL: Tutorials, https://pablometal1.github.io/quantumgui-web/tutorials.html
|
|
42
|
+
Keywords: gui,material-design-3,skia,gpu,desktop,python,erp,datagrid
|
|
43
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
44
|
+
Classifier: Intended Audience :: Developers
|
|
45
|
+
Classifier: License :: Other/Proprietary License
|
|
46
|
+
Classifier: Operating System :: OS Independent
|
|
47
|
+
Classifier: Programming Language :: Python :: 3
|
|
48
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
49
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
50
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
51
|
+
Requires-Python: >=3.11
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
License-File: LICENSE
|
|
54
|
+
Requires-Dist: skia-python>=130.0
|
|
55
|
+
Requires-Dist: glfw>=2.7.0
|
|
56
|
+
Requires-Dist: PyOpenGL>=3.1.7
|
|
57
|
+
Provides-Extra: dev
|
|
58
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
59
|
+
Provides-Extra: build
|
|
60
|
+
Requires-Dist: pyinstaller>=6.0; extra == "build"
|
|
61
|
+
Dynamic: license-file
|
|
62
|
+
|
|
63
|
+
# QuantumGUI
|
|
64
|
+
|
|
65
|
+
**Librería GUI nativa para Python acelerada por GPU (Skia + GLFW), diseñada 100% bajo los estándares de Material Design 3.**
|
|
66
|
+
|
|
67
|
+
Sin navegador embebido, sin WebView y sin dependencias de otros toolkits GUI (`tkinter`, Qt o wx). Interfaz fluida a 120 FPS con API declarativa en bloques `with`, modificadores encadenables y Suite Empresarial completa.
|
|
68
|
+
|
|
69
|
+
- **Web oficial:** https://pablometal1.github.io/quantumgui-web/
|
|
70
|
+
- **Documentación API (112 secciones):** https://pablometal1.github.io/quantumgui-web/docs.html
|
|
71
|
+
- **Tutoriales (36 capítulos):** https://pablometal1.github.io/quantumgui-web/tutorials.html
|
|
72
|
+
- **Roadmap (13/13 — v1.0.0):** https://pablometal1.github.io/quantumgui-web/roadmap.html
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Instalación
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install quantumgui
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Requiere **Python 3.11+**. Instala automáticamente `skia-python`, `glfw` y `PyOpenGL`.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Inicio Rápido
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from quantumgui import Theme, ui
|
|
90
|
+
|
|
91
|
+
theme = Theme(seed="#6750A4", mode="light")
|
|
92
|
+
contador = ui.state(0)
|
|
93
|
+
|
|
94
|
+
win = ui.window("Mi Primera App", width=760, height=440, theme=theme, main=True)
|
|
95
|
+
with win:
|
|
96
|
+
with ui.column(gap=16, align="stretch").padding(24):
|
|
97
|
+
with ui.row(justify="space_between", align="center").fill_width():
|
|
98
|
+
ui.text("QuantumGUI v1.0", role="headline_medium")
|
|
99
|
+
ui.switch(
|
|
100
|
+
label="Modo Oscuro",
|
|
101
|
+
on_change=lambda d: setattr(theme, "mode", "dark" if d else "light"),
|
|
102
|
+
)
|
|
103
|
+
with ui.card(variant="elevated", gap=12):
|
|
104
|
+
ui.text(lambda: f"Clicks: {contador.value}", role="title_large")
|
|
105
|
+
ui.button("Sumar +1", icon="add", on_click=lambda: setattr(contador, "value", contador.value + 1))
|
|
106
|
+
|
|
107
|
+
win.run()
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Características Principales (v1.0.0)
|
|
113
|
+
|
|
114
|
+
- **Renderizado 100% GPU nativo (Retained Mode):** Skia + GLFW + OpenGL con invalidación por demanda (0% consumo en reposo), soporte HiDPI/4K, física *M3 Expressive Spring* y *Ripple*.
|
|
115
|
+
- **Motor de Color Dinámico HCT (Material Design 3):** genera automáticamente todas las paletas tonales Light/Dark y niveles de contraste desde un único color `seed`.
|
|
116
|
+
- **Motor Universal de Estilos:** `.bg()`, `.fg()`, `.border()`, `.radius()`, `.elevation()`, `.opacity()`, `.size()`, `.padding()`, `.margin()`, `.tooltip()` en todos los controles.
|
|
117
|
+
- **95+ Controles M3 y 18 Gráficos GPU:** botones, formularios avanzados (`Autocomplete`, `TagInput`, `OTPInput`, `SignaturePad`, `DropZone`, `CurrencyInput`), productividad (`KanbanBoard`, `CalendarView`, `CommandPalette`, `PropertyGrid`), y gráficos BI (`Line`, `Bar`, `Donut`, `Candlestick`, `Treemap`, `Sankey`, `Waterfall`, `BoxPlot`, `Heatmap`, `Gantt`, `Sparkline`).
|
|
118
|
+
- **Suite Empresarial:**
|
|
119
|
+
- `ui.data_grid` virtualizado en $O(1)$ para **+100.000 filas a 120 FPS** (`page_size=100`, `virtualized=True`, edición inline, totales, CSV y Excel `.xlsx` nativo).
|
|
120
|
+
- `ui.sql_source` y `ui.csv_source` (conexión directa a SQLite, PostgreSQL, MySQL, SQL Server y SQLAlchemy con guardado `UPDATE` automático).
|
|
121
|
+
- `ui.rule_engine` (reglas de negocio reactivas y campos calculados), `ui.audit_log` + `ui.history` (Undo/Redo), `ui.master_detail`, `ui.pdf_report` multipágina vectorial, `ui.task_runner`, `ui.auth` (RBAC), `ui.i18n`, `ui.router`, `ui.preferences`.
|
|
122
|
+
- Ventanas personalizables (`frameless`, `transparent`, DWM Dark Mode y `titlebar_color` en Windows 10/11, `on_file_drop`, `ui.set_main_window`).
|
|
123
|
+
- **CLI oficial `quantumgui`:**
|
|
124
|
+
```bash
|
|
125
|
+
quantumgui info
|
|
126
|
+
quantumgui new mi_erp --template erp
|
|
127
|
+
quantumgui run mi_erp/main.py --watch # Hot-Reload automático
|
|
128
|
+
quantumgui build mi_erp/main.py # Ejecutable standalone .exe
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Licencia
|
|
134
|
+
|
|
135
|
+
**QuantumGUI Community & Commercial License v1.0** (ver `LICENSE`):
|
|
136
|
+
- **Gratis** para uso personal, educativo, open-source y proyectos/empresas con ingresos brutos anuales menores a **USD \$25.000**.
|
|
137
|
+
- **Licencia Comercial** requerida para organizaciones o proyectos comerciales con ingresos brutos anuales iguales o superiores a **USD \$25.000**.
|