qpuiq 0.23__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.
- PUI/PySide6/__init__.py +49 -0
- PUI/PySide6/application.py +58 -0
- PUI/PySide6/base.py +285 -0
- PUI/PySide6/button.py +21 -0
- PUI/PySide6/canvas.py +345 -0
- PUI/PySide6/checkbox.py +32 -0
- PUI/PySide6/combobox.py +85 -0
- PUI/PySide6/dialog.py +72 -0
- PUI/PySide6/divider.py +23 -0
- PUI/PySide6/image.py +48 -0
- PUI/PySide6/label.py +33 -0
- PUI/PySide6/layout.py +141 -0
- PUI/PySide6/matplotlib.py +23 -0
- PUI/PySide6/mdi.py +33 -0
- PUI/PySide6/menu.py +85 -0
- PUI/PySide6/modal.py +132 -0
- PUI/PySide6/progressbar.py +17 -0
- PUI/PySide6/radiobutton.py +29 -0
- PUI/PySide6/scroll.py +155 -0
- PUI/PySide6/splitter.py +25 -0
- PUI/PySide6/tab.py +39 -0
- PUI/PySide6/table.py +147 -0
- PUI/PySide6/text.py +35 -0
- PUI/PySide6/textfield.py +62 -0
- PUI/PySide6/toolbar.py +57 -0
- PUI/PySide6/tree.py +290 -0
- PUI/PySide6/window.py +82 -0
- PUI/__init__.py +46 -0
- PUI/common.py +26 -0
- PUI/decorator.py +20 -0
- PUI/dom.py +263 -0
- PUI/flet/__init__.py +22 -0
- PUI/flet/application.py +42 -0
- PUI/flet/base.py +37 -0
- PUI/flet/button.py +20 -0
- PUI/flet/canvas.py +86 -0
- PUI/flet/checkbox.py +23 -0
- PUI/flet/divider.py +14 -0
- PUI/flet/label.py +27 -0
- PUI/flet/layout.py +50 -0
- PUI/flet/progressbar.py +21 -0
- PUI/flet/radiobutton.py +27 -0
- PUI/flet/scroll.py +83 -0
- PUI/flet/tab.py +42 -0
- PUI/flet/text.py +55 -0
- PUI/flet/textfield.py +58 -0
- PUI/flet/window.py +25 -0
- PUI/interfaces.py +97 -0
- PUI/node.py +432 -0
- PUI/state.py +711 -0
- PUI/textual/__init__.py +35 -0
- PUI/textual/application.py +82 -0
- PUI/textual/base.py +148 -0
- PUI/textual/button.py +17 -0
- PUI/textual/checkbox.py +21 -0
- PUI/textual/label.py +36 -0
- PUI/textual/layout.py +52 -0
- PUI/textual/progressbar.py +17 -0
- PUI/textual/radiobutton.py +24 -0
- PUI/textual/scroll.py +74 -0
- PUI/textual/tab.py +75 -0
- PUI/textual/text.py +32 -0
- PUI/textual/textfield.py +55 -0
- PUI/textual/window.py +7 -0
- PUI/timeline.py +36 -0
- PUI/tkinter/__init__.py +43 -0
- PUI/tkinter/application.py +49 -0
- PUI/tkinter/base.py +68 -0
- PUI/tkinter/button.py +15 -0
- PUI/tkinter/canvas.py +52 -0
- PUI/tkinter/checkbox.py +27 -0
- PUI/tkinter/label.py +17 -0
- PUI/tkinter/layout.py +114 -0
- PUI/tkinter/progressbar.py +17 -0
- PUI/tkinter/radiobutton.py +26 -0
- PUI/tkinter/scroll.py +201 -0
- PUI/tkinter/tab.py +52 -0
- PUI/tkinter/text.py +20 -0
- PUI/tkinter/textfield.py +53 -0
- PUI/tkinter/window.py +51 -0
- PUI/utils.py +15 -0
- PUI/view.py +161 -0
- PUI/wx/__init__.py +19 -0
- PUI/wx/application.py +44 -0
- PUI/wx/base.py +246 -0
- PUI/wx/button.py +16 -0
- PUI/wx/canvas.py +255 -0
- PUI/wx/checkbox.py +25 -0
- PUI/wx/combobox.py +81 -0
- PUI/wx/dialog.py +66 -0
- PUI/wx/divider.py +19 -0
- PUI/wx/label.py +18 -0
- PUI/wx/layout.py +52 -0
- PUI/wx/progressbar.py +19 -0
- PUI/wx/radiobutton.py +27 -0
- PUI/wx/scroll.py +55 -0
- PUI/wx/text.py +23 -0
- PUI/wx/textfield.py +66 -0
- PUI/wx/window.py +64 -0
- qpuiq-0.23.dist-info/LICENSE.txt +21 -0
- qpuiq-0.23.dist-info/METADATA +234 -0
- qpuiq-0.23.dist-info/RECORD +104 -0
- qpuiq-0.23.dist-info/WHEEL +5 -0
- qpuiq-0.23.dist-info/top_level.txt +1 -0
PUI/PySide6/__init__.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from PySide6.QtWidgets import QSizePolicy, QLayout
|
|
2
|
+
|
|
3
|
+
from .application import *
|
|
4
|
+
from .button import *
|
|
5
|
+
from .canvas import *
|
|
6
|
+
from .checkbox import *
|
|
7
|
+
from .combobox import *
|
|
8
|
+
from .dialog import *
|
|
9
|
+
from .divider import *
|
|
10
|
+
from .image import *
|
|
11
|
+
from .label import *
|
|
12
|
+
from .layout import *
|
|
13
|
+
from .modal import *
|
|
14
|
+
from .matplotlib import *
|
|
15
|
+
from .progressbar import *
|
|
16
|
+
from .radiobutton import *
|
|
17
|
+
from .scroll import *
|
|
18
|
+
from .splitter import *
|
|
19
|
+
from .table import *
|
|
20
|
+
from .tab import *
|
|
21
|
+
from .text import *
|
|
22
|
+
from .textfield import *
|
|
23
|
+
from .tree import *
|
|
24
|
+
from .window import *
|
|
25
|
+
from .mdi import *
|
|
26
|
+
from .toolbar import *
|
|
27
|
+
|
|
28
|
+
PUIView = QtPUIView
|
|
29
|
+
|
|
30
|
+
def PUI(func):
|
|
31
|
+
"""
|
|
32
|
+
PUI.PySide6.PUI triggers update() by signal/slot
|
|
33
|
+
"""
|
|
34
|
+
def func_wrapper(*args, **kwargs):
|
|
35
|
+
class PUIViewWrapper(QtPUIView):
|
|
36
|
+
pui_virtual = True
|
|
37
|
+
def __init__(self, name):
|
|
38
|
+
self.name = name
|
|
39
|
+
super().__init__()
|
|
40
|
+
|
|
41
|
+
def content(self):
|
|
42
|
+
return func(*args, **kwargs)
|
|
43
|
+
|
|
44
|
+
ret = PUIViewWrapper(func.__name__)
|
|
45
|
+
return ret
|
|
46
|
+
|
|
47
|
+
return func_wrapper
|
|
48
|
+
|
|
49
|
+
PUI_BACKEND = "PySide6"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from .. import *
|
|
2
|
+
from .base import *
|
|
3
|
+
|
|
4
|
+
class QtApplicationSignal(QtCore.QObject):
|
|
5
|
+
quit = QtCore.Signal()
|
|
6
|
+
|
|
7
|
+
class Application(QtPUIView):
|
|
8
|
+
def __init__(self, icon=None):
|
|
9
|
+
super().__init__()
|
|
10
|
+
self.ui = None
|
|
11
|
+
self.icon = icon
|
|
12
|
+
self._qtappsignal = QtApplicationSignal()
|
|
13
|
+
self._qtappsignal.quit.connect(self._quit, QtCore.Qt.ConnectionType.QueuedConnection) # Use QueuedConnection to prevent nested trigger
|
|
14
|
+
|
|
15
|
+
def redraw(self):
|
|
16
|
+
if self.ui:
|
|
17
|
+
super().redraw()
|
|
18
|
+
else:
|
|
19
|
+
self.sync()
|
|
20
|
+
|
|
21
|
+
def update(self, prev=None):
|
|
22
|
+
if not self.ui:
|
|
23
|
+
from PySide6 import QtWidgets
|
|
24
|
+
self.ui = QtWidgets.QApplication([])
|
|
25
|
+
if self.icon:
|
|
26
|
+
self.ui.setWindowIcon(QtGui.QIcon(self.icon))
|
|
27
|
+
|
|
28
|
+
super().update(prev)
|
|
29
|
+
|
|
30
|
+
def addChild(self, idx, child):
|
|
31
|
+
child.outer.show()
|
|
32
|
+
|
|
33
|
+
def removeChild(self, idx, child):
|
|
34
|
+
child.outer.close()
|
|
35
|
+
|
|
36
|
+
def start(self):
|
|
37
|
+
self.ui.exec()
|
|
38
|
+
|
|
39
|
+
def quit(self):
|
|
40
|
+
self._qtappsignal.quit.emit()
|
|
41
|
+
|
|
42
|
+
def _quit(self):
|
|
43
|
+
self.ui.quit()
|
|
44
|
+
|
|
45
|
+
def PUIApp(func):
|
|
46
|
+
def func_wrapper(*args, **kwargs):
|
|
47
|
+
class PUIAppWrapper(Application):
|
|
48
|
+
def __init__(self, name):
|
|
49
|
+
self.name = name
|
|
50
|
+
super().__init__()
|
|
51
|
+
|
|
52
|
+
def content(self):
|
|
53
|
+
return func(*args, **kwargs)
|
|
54
|
+
|
|
55
|
+
ret = PUIAppWrapper(func.__name__)
|
|
56
|
+
return ret
|
|
57
|
+
|
|
58
|
+
return func_wrapper
|
PUI/PySide6/base.py
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
from .. import *
|
|
2
|
+
from PySide6 import QtCore, QtWidgets, QtGui
|
|
3
|
+
|
|
4
|
+
class QtViewSignal(QtCore.QObject):
|
|
5
|
+
redraw = QtCore.Signal()
|
|
6
|
+
|
|
7
|
+
def _apply_params(ui, node):
|
|
8
|
+
styles = {}
|
|
9
|
+
if node.style_fontsize:
|
|
10
|
+
styles["font"] = f"{node.style_fontsize}pt"
|
|
11
|
+
if node.style_fontfamily:
|
|
12
|
+
styles["font-family"] = node.style_fontfamily
|
|
13
|
+
if node.style_color:
|
|
14
|
+
styles["color"] = f"#{node.style_color:06X}"
|
|
15
|
+
if node.style_bgcolor:
|
|
16
|
+
styles["background-color"] = f"#{node.style_bgcolor:06X}"
|
|
17
|
+
|
|
18
|
+
style = node.qt_params.get("Style")
|
|
19
|
+
if not style is None:
|
|
20
|
+
ui.setStyle(style)
|
|
21
|
+
|
|
22
|
+
HorizontalPolicy = node.qt_params.get("HorizontalPolicy")
|
|
23
|
+
if not HorizontalPolicy is None:
|
|
24
|
+
ui.sizePolicy().setHorizontalPolicy(HorizontalPolicy)
|
|
25
|
+
|
|
26
|
+
VerticalPolicy = node.qt_params.get("VerticalPolicy")
|
|
27
|
+
if not VerticalPolicy is None:
|
|
28
|
+
ui.sizePolicy().setVerticalPolicy(VerticalPolicy)
|
|
29
|
+
|
|
30
|
+
SizeConstraint = node.qt_params.get("SizeConstraint")
|
|
31
|
+
if not SizeConstraint is None:
|
|
32
|
+
ui.setSizeConstraint(SizeConstraint)
|
|
33
|
+
|
|
34
|
+
StyleSheet = node.qt_params.get("StyleSheet", {})
|
|
35
|
+
for k,v in StyleSheet.items():
|
|
36
|
+
styles[k] = v
|
|
37
|
+
|
|
38
|
+
if hasattr(ui, "setStyleSheet"):
|
|
39
|
+
ui.setStyleSheet("".join([f"{k}:{v};" for k,v in styles.items()]))
|
|
40
|
+
|
|
41
|
+
if node.layout_padding:
|
|
42
|
+
ui.setContentsMargins(*trbl2ltrb(node.layout_padding))
|
|
43
|
+
|
|
44
|
+
class QtPUIView(PUIView):
|
|
45
|
+
pui_virtual = True
|
|
46
|
+
def __init__(self):
|
|
47
|
+
super().__init__()
|
|
48
|
+
self.qt_params = {}
|
|
49
|
+
self._qtsignal = QtViewSignal()
|
|
50
|
+
self._qtsignal.redraw.connect(self.sync, QtCore.Qt.ConnectionType.QueuedConnection) # Use QueuedConnection to prevent nested trigger
|
|
51
|
+
|
|
52
|
+
def destroy(self, direct):
|
|
53
|
+
if direct:
|
|
54
|
+
if self.ui: # PUIView doesn't have ui
|
|
55
|
+
self.ui.deleteLater()
|
|
56
|
+
self.ui = None
|
|
57
|
+
super().destroy(direct)
|
|
58
|
+
|
|
59
|
+
def redraw(self):
|
|
60
|
+
self.dirty = True
|
|
61
|
+
if self.updating:
|
|
62
|
+
return
|
|
63
|
+
self.updating = True
|
|
64
|
+
self._qtsignal.redraw.emit()
|
|
65
|
+
|
|
66
|
+
def update(self, prev=None):
|
|
67
|
+
super().update(prev)
|
|
68
|
+
_apply_params(self.ui, self)
|
|
69
|
+
|
|
70
|
+
def qt(self, **kwargs):
|
|
71
|
+
for k,v in kwargs.items():
|
|
72
|
+
self.qt_params[k] = v
|
|
73
|
+
return self
|
|
74
|
+
|
|
75
|
+
class EventFilter(QtCore.QObject):
|
|
76
|
+
def __init__(self):
|
|
77
|
+
super().__init__()
|
|
78
|
+
self.node = None
|
|
79
|
+
|
|
80
|
+
def eventFilter(self, obj, event):
|
|
81
|
+
node = self.node.get_node()
|
|
82
|
+
if event.type() == QtCore.QEvent.DragEnter:
|
|
83
|
+
return node.handleDragEnterEvent(event)
|
|
84
|
+
elif event.type() == QtCore.QEvent.Drop:
|
|
85
|
+
return node.handleDropEvent(event)
|
|
86
|
+
return super().eventFilter(obj, event)
|
|
87
|
+
|
|
88
|
+
class QtBaseWidget(PUINode):
|
|
89
|
+
pui_terminal = True
|
|
90
|
+
|
|
91
|
+
def __init__(self):
|
|
92
|
+
super().__init__()
|
|
93
|
+
self.qt_params = {}
|
|
94
|
+
|
|
95
|
+
def destroy(self, direct):
|
|
96
|
+
if direct:
|
|
97
|
+
if self.ui:
|
|
98
|
+
self.ui.deleteLater()
|
|
99
|
+
self.ui = None
|
|
100
|
+
super().destroy(direct)
|
|
101
|
+
|
|
102
|
+
def update(self, prev=None):
|
|
103
|
+
super().update(prev)
|
|
104
|
+
|
|
105
|
+
if prev:
|
|
106
|
+
self.eventFilter = prev.eventFilter
|
|
107
|
+
else:
|
|
108
|
+
self.eventFilter = EventFilter()
|
|
109
|
+
self.eventFilter.node = self
|
|
110
|
+
|
|
111
|
+
sizePolicy = self.ui.sizePolicy()
|
|
112
|
+
if self.layout_width is not None:
|
|
113
|
+
sizePolicy.setHorizontalPolicy(QtWidgets.QSizePolicy.Preferred)
|
|
114
|
+
if self.layout_height is not None:
|
|
115
|
+
sizePolicy.setVerticalPolicy(QtWidgets.QSizePolicy.Preferred)
|
|
116
|
+
self.ui.setSizePolicy(sizePolicy)
|
|
117
|
+
|
|
118
|
+
if not hasattr(self.ui, "origSizeHint"):
|
|
119
|
+
self.ui.origSizeHint = self.ui.sizeHint
|
|
120
|
+
self.ui.sizeHint = self.qtSizeHint
|
|
121
|
+
|
|
122
|
+
_apply_params(self.ui, self)
|
|
123
|
+
|
|
124
|
+
def postUpdate(self):
|
|
125
|
+
if self.ui:
|
|
126
|
+
if self._onDropped:
|
|
127
|
+
self.ui.setAcceptDrops(True)
|
|
128
|
+
self.ui.installEventFilter(self.eventFilter)
|
|
129
|
+
else:
|
|
130
|
+
self.ui.setAcceptDrops(False)
|
|
131
|
+
super().postUpdate()
|
|
132
|
+
|
|
133
|
+
def handleDragEnterEvent(self, event):
|
|
134
|
+
if self._onDragEntered:
|
|
135
|
+
return self._onDragEntered[0](event, *self._onDragEntered[1], **self._onDragEntered[2])
|
|
136
|
+
else:
|
|
137
|
+
event.ignore()
|
|
138
|
+
return True
|
|
139
|
+
|
|
140
|
+
def handleDropEvent(self, event):
|
|
141
|
+
if self._onDropped:
|
|
142
|
+
return self._onDropped[0](event, *self._onDropped[1], **self._onDropped[2])
|
|
143
|
+
else:
|
|
144
|
+
event.ignore()
|
|
145
|
+
return False
|
|
146
|
+
|
|
147
|
+
def qtSizeHint(self):
|
|
148
|
+
node = self.get_node()
|
|
149
|
+
if not node.ui:
|
|
150
|
+
return QtCore.QSize(0, 0)
|
|
151
|
+
sh = node.ui.origSizeHint()
|
|
152
|
+
w = sh.width()
|
|
153
|
+
h = sh.height()
|
|
154
|
+
if not node.layout_width is None:
|
|
155
|
+
w = node.layout_width
|
|
156
|
+
if not node.layout_height is None:
|
|
157
|
+
h = node.layout_height
|
|
158
|
+
return QtCore.QSize(w, h)
|
|
159
|
+
|
|
160
|
+
def qt(self, **kwargs):
|
|
161
|
+
for k,v in kwargs.items():
|
|
162
|
+
self.qt_params[k] = v
|
|
163
|
+
return self
|
|
164
|
+
|
|
165
|
+
class QtBaseLayout(QtBaseWidget):
|
|
166
|
+
pui_terminal = False
|
|
167
|
+
container_x = False
|
|
168
|
+
container_y = False
|
|
169
|
+
|
|
170
|
+
def __init__(self):
|
|
171
|
+
super().__init__()
|
|
172
|
+
self.qt_params = {}
|
|
173
|
+
if not isinstance(self.non_virtual_parent, QtBaseLayout):
|
|
174
|
+
self.layout_padding = (11,11,11,11)
|
|
175
|
+
|
|
176
|
+
@property
|
|
177
|
+
def outer(self):
|
|
178
|
+
return self.ui
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def inner(self):
|
|
182
|
+
return self.layout
|
|
183
|
+
|
|
184
|
+
def destroy(self, direct):
|
|
185
|
+
self.layout = None
|
|
186
|
+
super().destroy(direct)
|
|
187
|
+
|
|
188
|
+
def update(self, prev=None):
|
|
189
|
+
if prev and prev.ui:
|
|
190
|
+
self.mounted_children = prev.mounted_children
|
|
191
|
+
else:
|
|
192
|
+
self.mounted_children = []
|
|
193
|
+
|
|
194
|
+
super().update(prev)
|
|
195
|
+
|
|
196
|
+
def addChild(self, idx, child):
|
|
197
|
+
from .modal import Modal
|
|
198
|
+
from .layout import Spacer
|
|
199
|
+
if isinstance(child, Spacer):
|
|
200
|
+
self.qtlayout.insertItem(idx, child.outer)
|
|
201
|
+
self.mounted_children.insert(idx, child)
|
|
202
|
+
elif isinstance(child, Modal):
|
|
203
|
+
pass
|
|
204
|
+
elif isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
|
|
205
|
+
params = {}
|
|
206
|
+
if not child.layout_weight is None:
|
|
207
|
+
params["stretch"] = child.layout_weight
|
|
208
|
+
self.qtlayout.insertWidget(idx, child.outer, **params)
|
|
209
|
+
self.mounted_children.insert(idx, child)
|
|
210
|
+
|
|
211
|
+
def removeChild(self, idx, child):
|
|
212
|
+
from .modal import Modal
|
|
213
|
+
from .layout import Spacer
|
|
214
|
+
if isinstance(child, Spacer):
|
|
215
|
+
self.qtlayout.removeItem(child.outer)
|
|
216
|
+
self.mounted_children.pop(idx)
|
|
217
|
+
elif isinstance(child, Modal):
|
|
218
|
+
pass
|
|
219
|
+
elif isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
|
|
220
|
+
child.outer.setParent(None)
|
|
221
|
+
self.mounted_children.pop(idx)
|
|
222
|
+
|
|
223
|
+
def postUpdate(self):
|
|
224
|
+
if self.ui:
|
|
225
|
+
if self._onDropped:
|
|
226
|
+
self.ui.setAcceptDrops(True)
|
|
227
|
+
self.ui.installEventFilter(self.eventFilter)
|
|
228
|
+
else:
|
|
229
|
+
self.ui.setAcceptDrops(False)
|
|
230
|
+
|
|
231
|
+
super().postUpdate()
|
|
232
|
+
|
|
233
|
+
if self.container_x or self.container_y:
|
|
234
|
+
for i, child in enumerate(self.mounted_children):
|
|
235
|
+
child = child.get_node()
|
|
236
|
+
self.mounted_children[i] = child.get_node()
|
|
237
|
+
|
|
238
|
+
weight = child.layout_weight
|
|
239
|
+
self.qtlayout.setStretch(i, weight if weight else 0)
|
|
240
|
+
|
|
241
|
+
class QtBaseFrame(QtBaseWidget):
|
|
242
|
+
pui_terminal = False
|
|
243
|
+
|
|
244
|
+
def destroy(self, direct):
|
|
245
|
+
if direct:
|
|
246
|
+
if self.ui:
|
|
247
|
+
self.ui.deleteLater()
|
|
248
|
+
self.ui = None
|
|
249
|
+
|
|
250
|
+
def addChild(self, idx, child):
|
|
251
|
+
if idx != 0:
|
|
252
|
+
return
|
|
253
|
+
if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
|
|
254
|
+
self.ui.setWidget(child.outer)
|
|
255
|
+
elif child.children:
|
|
256
|
+
self.addChild(idx, child.children[0])
|
|
257
|
+
|
|
258
|
+
def removeChild(self, idx, child):
|
|
259
|
+
if idx != 0:
|
|
260
|
+
return
|
|
261
|
+
if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
|
|
262
|
+
child.outer.setParent(None)
|
|
263
|
+
elif child.children:
|
|
264
|
+
self.removeChild(idx, child.children[0])
|
|
265
|
+
|
|
266
|
+
class QtInPui(QtBaseWidget):
|
|
267
|
+
def __init__(self, widget, *args):
|
|
268
|
+
self._internal_tag = str(id(widget))
|
|
269
|
+
super().__init__(*args)
|
|
270
|
+
self.ui = widget
|
|
271
|
+
|
|
272
|
+
def destroy(self, direct):
|
|
273
|
+
pass
|
|
274
|
+
|
|
275
|
+
class PuiInQt(QtPUIView):
|
|
276
|
+
def __init__(self, ui):
|
|
277
|
+
super().__init__()
|
|
278
|
+
self.ui = ui
|
|
279
|
+
self.ui.update()
|
|
280
|
+
|
|
281
|
+
def addChild(self, idx, child):
|
|
282
|
+
self.ui.addChild(idx, child)
|
|
283
|
+
|
|
284
|
+
def removeChild(self, idx, child):
|
|
285
|
+
self.ui.removeChild(idx, child)
|
PUI/PySide6/button.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from .. import *
|
|
2
|
+
from .base import *
|
|
3
|
+
|
|
4
|
+
class Button(QtBaseWidget):
|
|
5
|
+
def __init__(self, text):
|
|
6
|
+
super().__init__()
|
|
7
|
+
self.text = text
|
|
8
|
+
|
|
9
|
+
def update(self, prev):
|
|
10
|
+
if prev and prev.ui:
|
|
11
|
+
self.ui = prev.ui
|
|
12
|
+
self.ui.setText(self.text)
|
|
13
|
+
try:
|
|
14
|
+
self.ui.clicked.disconnect()
|
|
15
|
+
except:
|
|
16
|
+
pass
|
|
17
|
+
prev.callback = None
|
|
18
|
+
else:
|
|
19
|
+
self.ui = QtWidgets.QPushButton(text=self.text)
|
|
20
|
+
self.ui.clicked.connect(self._clicked)
|
|
21
|
+
super().update(prev)
|