qpuiq 0.10__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.

Potentially problematic release.


This version of qpuiq might be problematic. Click here for more details.

Files changed (103) hide show
  1. PUI/PySide6/__init__.py +49 -0
  2. PUI/PySide6/application.py +58 -0
  3. PUI/PySide6/base.py +222 -0
  4. PUI/PySide6/button.py +21 -0
  5. PUI/PySide6/canvas.py +288 -0
  6. PUI/PySide6/checkbox.py +32 -0
  7. PUI/PySide6/combobox.py +75 -0
  8. PUI/PySide6/dialog.py +72 -0
  9. PUI/PySide6/divider.py +23 -0
  10. PUI/PySide6/image.py +30 -0
  11. PUI/PySide6/label.py +33 -0
  12. PUI/PySide6/layout.py +72 -0
  13. PUI/PySide6/matplotlib.py +23 -0
  14. PUI/PySide6/mdi.py +33 -0
  15. PUI/PySide6/menu.py +85 -0
  16. PUI/PySide6/modal.py +132 -0
  17. PUI/PySide6/progressbar.py +17 -0
  18. PUI/PySide6/radiobutton.py +29 -0
  19. PUI/PySide6/scroll.py +153 -0
  20. PUI/PySide6/splitter.py +25 -0
  21. PUI/PySide6/tab.py +39 -0
  22. PUI/PySide6/table.py +89 -0
  23. PUI/PySide6/text.py +35 -0
  24. PUI/PySide6/textfield.py +62 -0
  25. PUI/PySide6/toolbar.py +57 -0
  26. PUI/PySide6/tree.py +120 -0
  27. PUI/PySide6/window.py +81 -0
  28. PUI/__init__.py +46 -0
  29. PUI/common.py +20 -0
  30. PUI/decorator.py +20 -0
  31. PUI/dom.py +238 -0
  32. PUI/flet/__init__.py +21 -0
  33. PUI/flet/application.py +42 -0
  34. PUI/flet/base.py +37 -0
  35. PUI/flet/button.py +20 -0
  36. PUI/flet/canvas.py +86 -0
  37. PUI/flet/checkbox.py +23 -0
  38. PUI/flet/label.py +27 -0
  39. PUI/flet/layout.py +50 -0
  40. PUI/flet/progressbar.py +21 -0
  41. PUI/flet/radiobutton.py +27 -0
  42. PUI/flet/scroll.py +83 -0
  43. PUI/flet/tab.py +42 -0
  44. PUI/flet/text.py +55 -0
  45. PUI/flet/textfield.py +58 -0
  46. PUI/flet/window.py +25 -0
  47. PUI/interfaces.py +97 -0
  48. PUI/node.py +407 -0
  49. PUI/state.py +698 -0
  50. PUI/textual/__init__.py +34 -0
  51. PUI/textual/application.py +82 -0
  52. PUI/textual/base.py +113 -0
  53. PUI/textual/button.py +17 -0
  54. PUI/textual/checkbox.py +21 -0
  55. PUI/textual/label.py +36 -0
  56. PUI/textual/layout.py +48 -0
  57. PUI/textual/progressbar.py +17 -0
  58. PUI/textual/radiobutton.py +24 -0
  59. PUI/textual/scroll.py +72 -0
  60. PUI/textual/tab.py +75 -0
  61. PUI/textual/text.py +32 -0
  62. PUI/textual/textfield.py +49 -0
  63. PUI/textual/window.py +7 -0
  64. PUI/timeline.py +36 -0
  65. PUI/tkinter/__init__.py +43 -0
  66. PUI/tkinter/application.py +49 -0
  67. PUI/tkinter/base.py +68 -0
  68. PUI/tkinter/button.py +15 -0
  69. PUI/tkinter/canvas.py +49 -0
  70. PUI/tkinter/checkbox.py +27 -0
  71. PUI/tkinter/label.py +17 -0
  72. PUI/tkinter/layout.py +114 -0
  73. PUI/tkinter/progressbar.py +17 -0
  74. PUI/tkinter/radiobutton.py +26 -0
  75. PUI/tkinter/scroll.py +201 -0
  76. PUI/tkinter/tab.py +52 -0
  77. PUI/tkinter/text.py +20 -0
  78. PUI/tkinter/textfield.py +53 -0
  79. PUI/tkinter/window.py +51 -0
  80. PUI/utils.py +15 -0
  81. PUI/view.py +161 -0
  82. PUI/wx/__init__.py +19 -0
  83. PUI/wx/application.py +44 -0
  84. PUI/wx/base.py +202 -0
  85. PUI/wx/button.py +16 -0
  86. PUI/wx/canvas.py +255 -0
  87. PUI/wx/checkbox.py +25 -0
  88. PUI/wx/combobox.py +72 -0
  89. PUI/wx/dialog.py +66 -0
  90. PUI/wx/divider.py +19 -0
  91. PUI/wx/label.py +18 -0
  92. PUI/wx/layout.py +46 -0
  93. PUI/wx/progressbar.py +17 -0
  94. PUI/wx/radiobutton.py +27 -0
  95. PUI/wx/scroll.py +44 -0
  96. PUI/wx/text.py +23 -0
  97. PUI/wx/textfield.py +56 -0
  98. PUI/wx/window.py +58 -0
  99. qpuiq-0.10.dist-info/LICENSE.txt +21 -0
  100. qpuiq-0.10.dist-info/METADATA +227 -0
  101. qpuiq-0.10.dist-info/RECORD +103 -0
  102. qpuiq-0.10.dist-info/WHEEL +5 -0
  103. qpuiq-0.10.dist-info/top_level.txt +1 -0
PUI/node.py ADDED
@@ -0,0 +1,407 @@
1
+ import threading
2
+ from .utils import *
3
+ from .dom import *
4
+
5
+ tls = threading.local()
6
+
7
+ class PuiViewNotFoundError(Exception): pass
8
+
9
+ def find_puiview():
10
+ try:
11
+ return tls.puistack[-1]
12
+ except:
13
+ raise PuiViewNotFoundError()
14
+
15
+ class PUIEvent():
16
+ def __str__(self):
17
+ return str(self.__dict__)
18
+
19
+
20
+ class PUINode():
21
+ # To prevent crashes when we use a UI component not supported by the selected backend, this is useful when you are trying to support multiple backends.
22
+ pui_supported = True
23
+
24
+ # Tell DOM syncer not to go deeper into the node, it should be True for non-container elements
25
+ pui_terminal = False
26
+
27
+ # Menu and window-like UI elements, are out-of-order, so they are moved to the end of siblings before DOM syncing to simplify the process
28
+ pui_outoforder = False
29
+
30
+ # Used by PUIView
31
+ pui_isview = False
32
+
33
+ # Used by TimelineView, TabView, Sub-View or other nodes don't link to a real UI hierarchy
34
+ # Children of virtual nodes will be promoted to the same level as the virtual node, addChild/removeChild won't be called for virtual nodes
35
+ pui_virtual = False
36
+
37
+ # Used by grid layout, when enabled, sort children by grid_{row,column,rowspan,columnspan} before DOM sync
38
+ pui_grid_layout = False
39
+
40
+ def __init__(self, *args):
41
+ from .view import PUIView
42
+
43
+ if not hasattr(self, "name"):
44
+ self.name = None
45
+
46
+ self.destroyed = False
47
+ self.retired_by = None
48
+ self.pui_dom_parent = None
49
+ self._debug = 0
50
+ self._id = ""
51
+
52
+ self.layout_weight = None
53
+ self.layout_width = None
54
+ self.layout_height = None
55
+ self.layout_padding = None
56
+ self.layout_margin = None
57
+ self.style_color = None
58
+ self.style_bgcolor = None
59
+ self.style_fontsize = None
60
+ self.style_fontweight = None
61
+ self.style_fontfamily = None
62
+ self.grid_row = None
63
+ self.grid_column = None
64
+ self.grid_rowspan = None
65
+ self.grid_columnspan = None
66
+
67
+ self._onChanged = None
68
+ self._onClicked = None
69
+ self._onDblClicked = None
70
+ self._onInput = None
71
+ self._onKeyPress = None
72
+ self._onMouseDown = None
73
+ self._onMouseUp = None
74
+ self._onMouseMove = None
75
+ self._onWheel = None
76
+
77
+ self.ui = None
78
+ self.args = args
79
+ try:
80
+ self.root = find_puiview()
81
+ self.parent = self.root.frames[-1]
82
+ except PuiViewNotFoundError:
83
+ self.root = self
84
+ self.parent = self
85
+ self.frames = []
86
+
87
+ if isinstance(self, PUIView):
88
+ self.root = self
89
+
90
+ self.genKey()
91
+
92
+ self.children = []
93
+
94
+ if self.parent is self:
95
+ self._path = tuple()
96
+ else:
97
+ self._path = self.parent._path + tuple([len(self.parent.children)])
98
+ self.parent.children.append(self)
99
+
100
+ # print(type(self).__name__, self._path, "parent=", self.parent._path)
101
+
102
+ def findDomOffsetForNode(self, node):
103
+ if self is node:
104
+ return True, 0
105
+ offset = 0
106
+ for c in self.children:
107
+ if c is node:
108
+ return True, offset
109
+ if c.pui_virtual:
110
+ found, off = c.findDomOffsetForNode(node)
111
+ offset += off
112
+ if found:
113
+ return True, offset
114
+ elif not c.pui_outoforder:
115
+ offset += 1
116
+ return False, offset
117
+
118
+ def genKey(self):
119
+ # key has to be relative to PUIView, so that it can be identical when a sub-PUIView is updated individually
120
+ self.key = "|".join([x.name or type(x).__name__ for x in self.root.frames]+[self.name or type(self).__name__])
121
+ if self.grid_row is not None and self.grid_column is not None:
122
+ self.key += f":grid:{self.grid_row},{self.grid_column},{self.grid_rowspan},{self.grid_columnspan}"
123
+ if hasattr(self, "_internal_tag"):
124
+ self.key += f"%{self._internal_tag}"
125
+ if self._id:
126
+ self.key += f"#{self._id}"
127
+
128
+ def __enter__(self):
129
+ # print("enter", type(self).__name__, id(self))
130
+ self.root.frames.append(self)
131
+ return self
132
+
133
+ def __exit__(self, ex_type, value, traceback):
134
+ # print("exit", type(self).__name__, id(self))
135
+ self.root.frames.pop()
136
+ if ex_type is None: # don't consume exception
137
+ return self
138
+
139
+ @property
140
+ def non_virtual_parent(self):
141
+ p = self.parent
142
+ while p.pui_virtual:
143
+ p = p.parent
144
+ return p
145
+
146
+ @property
147
+ def inner(self):
148
+ if self.ui:
149
+ return self.ui
150
+ return self.parent.inner
151
+
152
+ @property
153
+ def outer(self):
154
+ if self.ui:
155
+ return self.ui
156
+ if self.children:
157
+ return self.children[0].outer
158
+ return None
159
+
160
+ def comment(self):
161
+ return None
162
+
163
+ def update(self, prev):
164
+ if prev and prev is not self:
165
+ prev.retired_by = self
166
+
167
+ def postUpdate(self):
168
+ pass
169
+
170
+ def preSync(self):
171
+ pass
172
+
173
+ def postSync(self):
174
+ pass
175
+
176
+ def destroy(self, direct):
177
+ self.root = None
178
+ self.parent = None
179
+ self.children = []
180
+
181
+ def addChild(self, idx, child):
182
+ pass
183
+
184
+ def removeChild(self, idx, child):
185
+ pass
186
+
187
+ def debug(self, level=1):
188
+ self._debug = level
189
+ return self
190
+
191
+ def id(self, name):
192
+ self._id = name
193
+ self.genKey()
194
+ return self
195
+
196
+ def get_node(self):
197
+ node = self
198
+ while node.retired_by:
199
+ node = node.retired_by
200
+ return node
201
+
202
+ def __repr__(self):
203
+ return self.serialize()
204
+
205
+ def serialize(self, show_key=True, show_pyid=False, show_hierarchy=False, layout_debug=False):
206
+ segs = []
207
+ headline = [
208
+ " "*len(self._path),
209
+ self.name or type(self).__name__,
210
+ ]
211
+ if show_pyid:
212
+ headline.append(f"@{id(self)}")
213
+ if self.children:
214
+ headline.append(" {")
215
+
216
+ # print view key
217
+ if show_key:
218
+ headline.append(" # Key: ")
219
+ headline.append(self.key)
220
+
221
+ if show_hierarchy:
222
+ headline.append(f" # parent={id(self.parent) if self.parent else None}")
223
+
224
+ if layout_debug:
225
+ headline.append(" # Layout:")
226
+ if hasattr(self, "expand_x"):
227
+ headline.append(f" expand_x={self.expand_x}")
228
+ if hasattr(self, "expand_y"):
229
+ headline.append(f" expand_y={self.expand_y}")
230
+ if hasattr(self, "strong_expand_x"):
231
+ headline.append(f" strong_expand_x={self.strong_expand_x}")
232
+ if hasattr(self, "strong_expand_y"):
233
+ headline.append(f" strong_expand_y={self.strong_expand_y}")
234
+ if hasattr(self, "weak_expand_x"):
235
+ headline.append(f" weak_expand_x={self.weak_expand_x}")
236
+ if hasattr(self, "weak_expand_y"):
237
+ headline.append(f" weak_expand_y={self.weak_expand_y}")
238
+ if hasattr(self, "nweak_expand_x"):
239
+ headline.append(f" nweak_expand_x={self.nweak_expand_x}")
240
+ if hasattr(self, "nweak_expand_y"):
241
+ headline.append(f" nweak_expand_y={self.nweak_expand_y}")
242
+ if hasattr(self, "strong_expand_x_children"):
243
+ headline.append(f" strong_expand_x_children={self.strong_expand_x_children}")
244
+ if hasattr(self, "strong_expand_y_children"):
245
+ headline.append(f" strong_expand_y_children={self.strong_expand_y_children}")
246
+
247
+ if self.children:
248
+ headline.append("\n")
249
+ segs.append("".join(headline))
250
+
251
+ comment = self.comment()
252
+ if comment:
253
+ segs.append(" "*(len(self._path)+1))
254
+ segs.append("# ")
255
+ segs.append(comment)
256
+ segs.append("\n")
257
+
258
+ if self.children:
259
+ for i,c in enumerate(self.children):
260
+ if i > 0:
261
+ segs.append("\n")
262
+ segs.append(c.serialize(show_key=show_key, show_pyid=show_pyid, show_hierarchy=show_hierarchy, layout_debug=layout_debug))
263
+ segs.append("\n")
264
+ segs.append("".join([" "*len(self._path), "}"]))
265
+ return "".join(segs)
266
+
267
+ def layout(self, width=None, height=None, weight=None, padding=None, margin=None):
268
+ if not width is None:
269
+ self.layout_width = width
270
+ if not height is None:
271
+ self.layout_height = height
272
+ if not weight is None:
273
+ self.layout_weight = weight
274
+ if not padding is None:
275
+ self.layout_padding = trbl(padding)
276
+ if not margin is None:
277
+ self.layout_margin = trbl(margin)
278
+
279
+ return self
280
+
281
+ def style(self, color=None, bgColor=None, fontSize=None, fontWeight=None, fontFamily=None):
282
+ if not color is None:
283
+ self.style_color = color
284
+ if not bgColor is None:
285
+ self.style_bgcolor = bgColor
286
+ if not fontSize is None:
287
+ self.style_fontsize = fontSize
288
+ if not fontWeight is None:
289
+ self.style_fontweight = fontWeight
290
+ if not fontFamily is None:
291
+ self.style_fontfamily = fontFamily
292
+
293
+ return self
294
+
295
+ def grid(self, row=None, column=None, rowspan=None, columnspan=None):
296
+ if row is not None:
297
+ self.grid_row = row
298
+ if column is not None:
299
+ self.grid_column = column
300
+ if rowspan is not None:
301
+ self.grid_rowspan = rowspan
302
+ if columnspan is not None:
303
+ self.grid_columnspan = columnspan
304
+ self.genKey()
305
+ return self
306
+
307
+ def click(self, callback, *cb_args, **cb_kwargs):
308
+ self._onClicked = callback, cb_args, cb_kwargs
309
+ return self
310
+
311
+ def _clicked(self, e=None, *args, **kwargs):
312
+ node = self.get_node()
313
+ if node._onClicked:
314
+ cb, cb_args, cb_kwargs = node._onClicked
315
+ cb(e, *cb_args, **cb_kwargs)
316
+
317
+ def dblclick(self, callback, *cb_args, **cb_kwargs):
318
+ self._onDblClicked = callback, cb_args, cb_kwargs
319
+ return self
320
+
321
+ def _dblclicked(self, e, *args, **kwargs):
322
+ node = self.get_node()
323
+ if node._onDblClicked:
324
+ cb, cb_args, cb_kwargs = node._onDblClicked
325
+ cb(e, *cb_args, **cb_kwargs)
326
+
327
+ def change(self, callback, *cb_args, **cb_kwargs):
328
+ self._onChanged = callback, cb_args, cb_kwargs
329
+ return self
330
+
331
+ def _change(self, e, *args, **kwargs):
332
+ node = self.get_node()
333
+ if node._onChanged:
334
+ cb, cb_args, cb_kwargs = node._onChanged
335
+ cb(e, *cb_args, **cb_kwargs)
336
+
337
+ def input(self, callback, *cb_args, **cb_kwargs):
338
+ self._onInput = callback, cb_args, cb_kwargs
339
+ return self
340
+
341
+ def _input(self, e, *args, **kwargs):
342
+ node = self.get_node()
343
+ if node._onInput:
344
+ cb, cb_args, cb_kwargs = node._onInput
345
+ cb(e, *cb_args, **cb_kwargs)
346
+
347
+ def mousedown(self, callback, *cb_args, **cb_kwargs):
348
+ self._onMouseDown = callback, cb_args, cb_kwargs
349
+ return self
350
+
351
+ def _mousedown(self, e, *args, **kwargs):
352
+ node = self.get_node()
353
+ if node._onMouseDown:
354
+ cb, cb_args, cb_kwargs = node._onMouseDown
355
+ cb(e, *cb_args, **cb_kwargs)
356
+
357
+ def mouseup(self, callback, *cb_args, **cb_kwargs):
358
+ self._onMouseUp = callback, cb_args, cb_kwargs
359
+ return self
360
+
361
+ def _mouseup(self, e, *args, **kwargs):
362
+ node = self.get_node()
363
+ if node._onMouseUp:
364
+ cb, cb_args, cb_kwargs = node._onMouseUp
365
+ cb(e, *cb_args, **cb_kwargs)
366
+
367
+ def mousemove(self, callback, *cb_args, **cb_kwargs):
368
+ self._onMouseMove = callback, cb_args, cb_kwargs
369
+ return self
370
+
371
+ def _mousemove(self, e, *args, **kwargs):
372
+ node = self.get_node()
373
+ if node._onMouseMove:
374
+ cb, cb_args, cb_kwargs = node._onMouseMove
375
+ cb(e, *cb_args, **cb_kwargs)
376
+
377
+ def wheel(self, callback, *cb_args, **cb_kwargs):
378
+ self._onWheel = callback, cb_args, cb_kwargs
379
+ return self
380
+
381
+ def _wheel(self, e, *args, **kwargs):
382
+ node = self.get_node()
383
+ if node._onWheel:
384
+ cb, cb_args, cb_kwargs = node._onWheel
385
+ cb(e, *cb_args, **cb_kwargs)
386
+
387
+ def keypress(self, callback, *cb_args, **cb_kwargs):
388
+ self._onKeyPress = callback, cb_args, cb_kwargs
389
+ return self
390
+
391
+ def _keypress(self, e, *args, **kwargs):
392
+ node = self.get_node()
393
+ if node._onKeyPress:
394
+ cb, cb_args, cb_kwargs = node._onKeyPress
395
+ cb(e, *cb_args, **cb_kwargs)
396
+
397
+ def flet(self, **kwargs):
398
+ return self
399
+
400
+ def textual(self, **kwargs):
401
+ return self
402
+
403
+ def tkinter(self, **kwargs):
404
+ return self
405
+
406
+ def qt(self, **kwargs):
407
+ return self