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
@@ -0,0 +1,75 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class ComboBox(QtBaseWidget):
5
+ pui_terminal = False
6
+ def __init__(self, editable=False, index_model=None, text_model=None):
7
+ super().__init__()
8
+ self.editable = editable
9
+ self.index_model = index_model
10
+ self.text_model = text_model
11
+
12
+ def update(self, prev):
13
+ if prev and prev.ui:
14
+ self.curr_index = prev.curr_index
15
+ self.curr_text = prev.curr_text
16
+ self.signal_connected = prev.signal_connected
17
+ self.ui = prev.ui
18
+ else:
19
+ self.curr_index = Prop()
20
+ self.curr_text = Prop()
21
+ self.signal_connected = False
22
+ self.ui = QtWidgets.QComboBox()
23
+ self.ui.setEditable(self.editable)
24
+ super().update(prev)
25
+
26
+ def postSync(self):
27
+ if self.index_model:
28
+ index = self.index_model.value
29
+ text = self.children[index].text
30
+ elif self.text_model:
31
+ text = str(self.text_model.value)
32
+ try:
33
+ index = [c.text for c in self.children].index(text)
34
+ except:
35
+ index = 0
36
+
37
+ if self.signal_connected:
38
+ self.ui.currentIndexChanged.disconnect()
39
+ self.ui.currentTextChanged.disconnect()
40
+
41
+ if self.curr_index.set(index):
42
+ self.ui.setCurrentIndex(index)
43
+
44
+ if self.curr_text.set(text):
45
+ self.ui.setCurrentText(text)
46
+
47
+ self.ui.currentIndexChanged.connect(self.on_currentIndexChanged)
48
+ self.ui.currentTextChanged.connect(self.on_currentTextChanged)
49
+
50
+
51
+ def on_currentIndexChanged(self, idx):
52
+ if self.index_model:
53
+ self.index_model.value = idx
54
+ e = PUIEvent()
55
+ e.value = idx
56
+ self._change(e)
57
+
58
+ def on_currentTextChanged(self, text):
59
+ if self.text_model:
60
+ self.text_model.value = text
61
+ e = PUIEvent()
62
+ e.value = text
63
+ self._change(e)
64
+
65
+ def addChild(self, idx, child):
66
+ self.ui.insertItem(idx, child.text)
67
+
68
+ def removeChild(self, idx, child):
69
+ self.ui.removeItem(idx)
70
+
71
+ class ComboBoxItem(PUINode):
72
+ def __init__(self, text):
73
+ super().__init__()
74
+ self.id(text)
75
+ self.text = text
PUI/PySide6/dialog.py ADDED
@@ -0,0 +1,72 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ def OpenDirectory(title="Open Directory", dir=None):
5
+ res = QtWidgets.QFileDialog.getExistingDirectory(None, title, dir)
6
+ return res
7
+
8
+ def OpenFile(title="Open File", dir=None, types=None):
9
+ if types:
10
+ types = types.replace("|", ";;")
11
+ res = QtWidgets.QFileDialog.getOpenFileName(None, title, dir, types)
12
+ return res[0] or None
13
+
14
+ def OpenFiles(title="Open Files", dir=None, types=None):
15
+ if types:
16
+ types = types.replace("|", ";;")
17
+ res = QtWidgets.QFileDialog.getOpenFileNames(None, title, dir, types)
18
+ return res[0] or None
19
+
20
+ def SaveFile(default, title="Save File", dir=None, types=None):
21
+ if types:
22
+ types = types.replace("|", ";;")
23
+ if not dir:
24
+ value = default
25
+ if isinstance(value, str):
26
+ dir = value
27
+ res = QtWidgets.QFileDialog.getSaveFileName(None, title, dir, types)
28
+ return res[0] or None
29
+
30
+ def Information(message="Information", title="Information Dialog"):
31
+ dlg = QtWidgets.QMessageBox(None)
32
+ dlg.setWindowTitle(title)
33
+ dlg.setText(message)
34
+ dlg.setStandardButtons(QtWidgets.QMessageBox.Ok)
35
+ dlg.setIcon(QtWidgets.QMessageBox.Information)
36
+ dlg.exec_()
37
+
38
+ def Warning(message="Warning", title="Warning Dialog"):
39
+ dlg = QtWidgets.QMessageBox(None)
40
+ dlg.setWindowTitle(title)
41
+ dlg.setText(message)
42
+ dlg.setStandardButtons(QtWidgets.QMessageBox.Ok)
43
+ dlg.setIcon(QtWidgets.QMessageBox.Warning)
44
+ dlg.exec_()
45
+
46
+ def Critical(message="Critical", title="Critical Dialog"):
47
+ dlg = QtWidgets.QMessageBox(None)
48
+ dlg.setWindowTitle(title)
49
+ dlg.setText(message)
50
+ dlg.setStandardButtons(QtWidgets.QMessageBox.Ok)
51
+ dlg.setIcon(QtWidgets.QMessageBox.Critical)
52
+ dlg.exec_()
53
+
54
+ def Confirm(message="Confirm", title="Confirm Dialog"):
55
+ dlg = QtWidgets.QMessageBox(None)
56
+ dlg.setWindowTitle(title)
57
+ dlg.setText(message)
58
+ dlg.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
59
+ dlg.setIcon(QtWidgets.QMessageBox.Question)
60
+ button = dlg.exec_()
61
+
62
+ if button == QtWidgets.QMessageBox.Yes:
63
+ return True
64
+ else:
65
+ return False
66
+
67
+ def Prompt(prompt="Input", title="Input Dialog", default=""):
68
+ text, ok = QtWidgets.QInputDialog.getText(None, title, prompt, QtWidgets.QLineEdit.Normal, default)
69
+ if ok:
70
+ return text
71
+ else:
72
+ return None
PUI/PySide6/divider.py ADDED
@@ -0,0 +1,23 @@
1
+ from .. import *
2
+ from .base import *
3
+ from .layout import *
4
+
5
+ class Divider(QtBaseWidget):
6
+ def __init__(self):
7
+ super().__init__()
8
+
9
+ def update(self, prev):
10
+ if prev and prev.ui:
11
+ self.ui = prev.ui
12
+ else:
13
+ self.ui = QtWidgets.QFrame()
14
+ parent = self.non_virtual_parent
15
+ if isinstance(parent, VBox):
16
+ self.ui.setFrameShape(QtWidgets.QFrame.Shape.HLine)
17
+ elif isinstance(parent, HBox):
18
+ self.ui.setFrameShape(QtWidgets.QFrame.Shape.VLine)
19
+ else:
20
+ self.ui.setFrameShape(QtWidgets.QFrame.Shape.NoFrame)
21
+ self.ui.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
22
+
23
+ super().update(prev)
PUI/PySide6/image.py ADDED
@@ -0,0 +1,30 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class Image(QtBaseWidget):
5
+ def __init__(self, path):
6
+ super().__init__()
7
+ self.path = path
8
+ self.pixmap = None
9
+
10
+ def update(self, prev):
11
+ if prev and prev.ui:
12
+ self.ui = prev.ui
13
+ self.curr_path = prev.curr_path
14
+ self.pixmap = prev.pixmap
15
+ else:
16
+ self.ui = QtWidgets.QLabel()
17
+ self.curr_path = Prop()
18
+
19
+ if self.curr_path.set(self.path):
20
+ self.pixmap = QtGui.QPixmap(self.path)
21
+ if self.layout_width is not None and self.layout_height is not None:
22
+ self.pixmap = self.pixmap.scaled(self.layout_width, self.layout_height, QtCore.Qt.KeepAspectRatio, mode=QtCore.Qt.SmoothTransformation)
23
+ elif self.layout_width is not None:
24
+ self.pixmap = self.pixmap.scaledToWidth(self.layout_width, mode=QtCore.Qt.SmoothTransformation)
25
+ elif self.layout_height is not None:
26
+ self.pixmap = self.pixmap.scaledToHeight(self.layout_height, mode=QtCore.Qt.SmoothTransformation)
27
+
28
+ self.ui.setPixmap(self.pixmap)
29
+
30
+ super().update(prev)
PUI/PySide6/label.py ADDED
@@ -0,0 +1,33 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class ClickableQLabel(QtWidgets.QLabel):
5
+ clicked = QtCore.Signal()
6
+
7
+ def mousePressEvent(self, ev):
8
+ self.clicked.emit()
9
+ super().mousePressEvent(ev)
10
+
11
+ class Label(QtBaseWidget):
12
+ def __init__(self, text, selectable=False):
13
+ super().__init__()
14
+ self.text = str(text)
15
+ self.selectable = selectable
16
+
17
+ def update(self, prev):
18
+ if prev and prev.ui:
19
+ self.ui = prev.ui
20
+ self.ui.setText(self.text)
21
+ else:
22
+ self.ui = ClickableQLabel(self.text)
23
+ self.ui.setTextFormat(QtCore.Qt.TextFormat.PlainText)
24
+ self.ui.clicked.connect(self._clicked)
25
+ if self._onClicked:
26
+ self.ui.setCursor(QtCore.Qt.PointingHandCursor)
27
+
28
+ if self.selectable:
29
+ self.ui.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
30
+ else:
31
+ self.ui.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.NoTextInteraction)
32
+
33
+ super().update(prev)
PUI/PySide6/layout.py ADDED
@@ -0,0 +1,72 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class HBox(QtBaseLayout):
5
+ def update(self, prev):
6
+ if prev and prev.ui:
7
+ self.ui = prev.ui
8
+ self.layout = prev.layout
9
+ else:
10
+ self.ui = QtWidgets.QWidget()
11
+ self.layout = QtWidgets.QHBoxLayout()
12
+ self.layout.setContentsMargins(0,0,0,0)
13
+ self.ui.setLayout(self.layout)
14
+ super().update(prev)
15
+
16
+ class VBox(QtBaseLayout):
17
+ def update(self, prev):
18
+ if prev and prev.ui:
19
+ self.ui = prev.ui
20
+ self.layout = prev.layout
21
+ else:
22
+ self.ui = QtWidgets.QWidget()
23
+ self.layout = QtWidgets.QVBoxLayout()
24
+ self.layout.setContentsMargins(0,0,0,0)
25
+ self.ui.setLayout(self.layout)
26
+ super().update(prev)
27
+
28
+ class Spacer(PUINode):
29
+ pui_terminal = True
30
+
31
+ def update(self, prev):
32
+ if prev and prev.ui:
33
+ self.ui = prev.ui
34
+ else:
35
+ if isinstance(self.non_virtual_parent, VBox):
36
+ self.ui = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
37
+ elif isinstance(self.non_virtual_parent, HBox):
38
+ self.ui = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
39
+ else:
40
+ self.ui = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
41
+ super().update(prev)
42
+
43
+ def destroy(self, direct):
44
+ # self.ui.deleteLater() # QSpacerItem doesn't have .deleteLater()
45
+ self.ui = None
46
+ super().destroy(direct)
47
+
48
+ class Grid(QtBaseLayout):
49
+ pui_grid_layout = True
50
+
51
+ def update(self, prev):
52
+ if prev and prev.ui:
53
+ self.ui = prev.ui
54
+ self.layout = prev.layout
55
+ else:
56
+ self.ui = QtWidgets.QWidget()
57
+ self.layout = QtWidgets.QGridLayout()
58
+ self.layout.setContentsMargins(0,0,0,0)
59
+ self.ui.setLayout(self.layout)
60
+ super().update(prev)
61
+
62
+ def addChild(self, idx, child):
63
+ if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
64
+ self.layout.addWidget(child.outer, child.grid_row, child.grid_column, child.grid_rowspan or 1, child.grid_columnspan or 1)
65
+ elif child.children:
66
+ self.addChild(idx, child.children[0])
67
+
68
+ def removeChild(self, idx, child):
69
+ if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
70
+ child.outer.setParent(None)
71
+ elif child.children:
72
+ self.removeChild(idx, child.children[0])
@@ -0,0 +1,23 @@
1
+ from .base import *
2
+
3
+ class MatplotlibCanvas(QtBaseWidget):
4
+ def __init__(self, plotter, *args, **kwargs):
5
+ super().__init__()
6
+ self.plotter = plotter
7
+ self.args = args
8
+ self.kwargs = kwargs
9
+
10
+ def update(self, prev):
11
+ from matplotlib.backends.backend_qtagg import FigureCanvas
12
+ from matplotlib.backends.backend_qtagg import NavigationToolbar2QT as NavigationToolbar
13
+ from matplotlib.backends.qt_compat import QtWidgets
14
+ from matplotlib.figure import Figure
15
+ if prev and prev.ui:
16
+ self.figure = prev.figure
17
+ self.ui = prev.ui
18
+ else:
19
+ self.figure = Figure()
20
+ self.ui = FigureCanvas(self.figure)
21
+ self.plotter(self.figure, *self.args, **self.kwargs)
22
+ self.ui.draw()
23
+ super().update(prev)
PUI/PySide6/mdi.py ADDED
@@ -0,0 +1,33 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class MdiArea(QtBaseWidget):
5
+ pui_terminal = False
6
+ def update(self, prev):
7
+ if prev and prev.ui:
8
+ self.ui = prev.ui
9
+ else:
10
+ self.ui = QtWidgets.QMdiArea()
11
+
12
+ super().update(prev)
13
+
14
+ def addChild(self, idx, child):
15
+ self.ui.addSubWindow(child.outer)
16
+
17
+ def removeChild(self, idx, child):
18
+ self.ui.removeSubWindow(child.outer)
19
+
20
+ def addSubWindow(self, child):
21
+ self.ui.addSubWindow(child.outer)
22
+
23
+ def removeSubWindow(self, child):
24
+ self.ui.removeSubWindow(child.outer)
25
+
26
+ class MdiSubWindow(QtBaseFrame):
27
+ def update(self, prev):
28
+ if prev and prev.ui:
29
+ self.ui = prev.ui
30
+ else:
31
+ self.ui = QtWidgets.QMdiSubWindow()
32
+
33
+ super().update(prev)
PUI/PySide6/menu.py ADDED
@@ -0,0 +1,85 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class MenuBar(PUINode):
5
+ pui_outoforder = True
6
+ def update(self, prev):
7
+ if prev and prev.ui:
8
+ self.ui = prev.ui
9
+ self.actions = prev.actions
10
+ else:
11
+ self.ui = QtWidgets.QMenuBar()
12
+ self.actions = []
13
+
14
+ super().update(prev)
15
+
16
+ def addChild(self, idx, child):
17
+ if idx < len(self.actions):
18
+ if isinstance(child, Menu):
19
+ self.actions.insert(idx, self.ui.insertMenu(self.actions[idx], child.outer))
20
+ elif isinstance(child, MenuAction):
21
+ self.actions.insert(idx, self.ui.insertAction(self.actions[idx], child.outer))
22
+ else:
23
+ if isinstance(child, Menu):
24
+ self.actions.append(self.ui.addMenu(child.outer))
25
+ elif isinstance(child, MenuAction):
26
+ self.actions.append(self.ui.addAction(child.outer))
27
+
28
+ def removeChild(self, idx, child):
29
+ self.ui.removeAction(self.actions[idx])
30
+
31
+ class Menu(PUINode):
32
+ def __init__(self, text):
33
+ super().__init__()
34
+ self.text = text
35
+
36
+ def update(self, prev):
37
+ if prev and prev.ui:
38
+ self.ui = prev.ui
39
+ self.ui.setTitle(self.text)
40
+ self.actions = prev.actions
41
+ else:
42
+ self.ui = QtWidgets.QMenu(self.text)
43
+ self.actions = []
44
+
45
+ super().update(prev)
46
+
47
+ def addChild(self, idx, child):
48
+ if idx < len(self.actions):
49
+ if isinstance(child, Menu):
50
+ self.actions.insert(idx, self.ui.insertMenu(self.actions[idx], child.outer))
51
+ elif isinstance(child, MenuAction):
52
+ self.actions.insert(idx, self.ui.insertAction(self.actions[idx], child.outer))
53
+ else:
54
+ if isinstance(child, Menu):
55
+ self.actions.append(self.ui.addMenu(child.outer))
56
+ elif isinstance(child, MenuAction):
57
+ self.actions.append(self.ui.addAction(child.outer))
58
+
59
+ def removeChild(self, idx, child):
60
+ self.ui.removeAction(self.actions[idx])
61
+
62
+ class MenuAction(PUINode):
63
+ def __init__(self, text):
64
+ super().__init__()
65
+ self.text = text
66
+ self.onTriggered = None
67
+
68
+ def update(self, prev):
69
+ if prev and prev.ui:
70
+ self.ui = prev.ui
71
+ self.ui.setText(self.text)
72
+ self.ui.triggered.disconnect()
73
+ else:
74
+ self.ui = QtGui.QAction(self.text)
75
+ self.ui.triggered.connect(self._triggered)
76
+
77
+ super().update(prev)
78
+
79
+ def _triggered(self):
80
+ node = self.get_node()
81
+ if node.onTriggered:
82
+ node.onTriggered[0](*node.onTriggered[1], **node.onTriggered[2])
83
+
84
+ def trigger(self, callback, *cb_args, **cb_kwargs):
85
+ self.onTriggered = (callback, cb_args, cb_kwargs)
PUI/PySide6/modal.py ADDED
@@ -0,0 +1,132 @@
1
+ from .. import *
2
+ from .base import *
3
+ from .menu import *
4
+
5
+ class QtModal(QtWidgets.QDialog):
6
+ def closeEvent(self, arg__1) -> None:
7
+ self.puinode._close()
8
+ return super().closeEvent(arg__1)
9
+
10
+ class Modal(QtBaseWidget):
11
+ pui_terminal = False
12
+ pui_outoforder = True
13
+
14
+ def __init__(self, status, offValue=None, title=None, size=None, maximize=None, fullscreen=None):
15
+ super().__init__()
16
+ self.status = status
17
+ self.offValue = offValue
18
+ self.title = title
19
+ self.size = size
20
+ self.maximize = maximize
21
+ self.fullscreen = fullscreen
22
+ self.open_cb = None
23
+ self.close_cb = None
24
+
25
+ @property
26
+ def outer(self):
27
+ return self.ui
28
+
29
+ @property
30
+ def inner(self):
31
+ return self.layout
32
+
33
+ def destroy(self, direct):
34
+ self.close_modal()
35
+ return super().destroy(direct)
36
+
37
+ def update(self, prev=None):
38
+ if prev and prev.ui:
39
+ self.ui = prev.ui
40
+ self.curr_size = prev.curr_size
41
+ self.curr_maximize = prev.curr_maximize
42
+ self.curr_fullscreen = prev.curr_fullscreen
43
+ self.curr_status = prev.curr_status
44
+ else:
45
+ self.ui = QtModal()
46
+ self.ui.setModal(True)
47
+ self.layout = QtWidgets.QVBoxLayout()
48
+ self.ui.setLayout(self.layout)
49
+ self.layout.setContentsMargins(0,0,0,0)
50
+ self.curr_size = Prop()
51
+ self.curr_maximize = Prop()
52
+ self.curr_fullscreen = Prop()
53
+ self.curr_status = Prop()
54
+
55
+ if self.curr_size.set(self.size):
56
+ self.ui.resize(*self.size)
57
+ if self.curr_maximize.set(self.maximize):
58
+ self.ui.showMaximized()
59
+ if self.curr_fullscreen.set(self.fullscreen):
60
+ self.ui.showFullScreen()
61
+ if not self.title is None:
62
+ self.ui.setWindowTitle(self.title)
63
+
64
+ self.ui.puinode = self
65
+
66
+ if self.status.value:
67
+ self.open_modal()
68
+ else:
69
+ self.close_modal()
70
+ super().update(prev)
71
+
72
+ def open(self, cb, *args, **kwargs):
73
+ self.open_cb = (cb, args, kwargs)
74
+ return self
75
+
76
+ def close(self, cb, *args, **kwargs):
77
+ self.close_cb = (cb, args, kwargs)
78
+ return self
79
+
80
+ def open_modal(self):
81
+ if not self.curr_status:
82
+ self.ui.show()
83
+ self.curr_status = True
84
+ if self.open_cb:
85
+ self.open_cb[0](*self.open_cb[1], **self.open_cb[2])
86
+
87
+ def close_modal(self):
88
+ prev_status = self.curr_status
89
+ if self.curr_status is None or self.curr_status:
90
+ self.curr_status = False
91
+ if prev_status:
92
+ self.ui.close()
93
+ if self.close_cb:
94
+ self.close_cb[0](*self.close_cb[1], **self.close_cb[2])
95
+
96
+ def _close(self, *args, **kwargs):
97
+ node = self.get_node()
98
+ if node.curr_status:
99
+ node.curr_status = False
100
+ if node.close_cb:
101
+ node.close_cb[0](*node.close_cb[1], **node.close_cb[2])
102
+ node.status.value = node.offValue
103
+
104
+
105
+ def addChild(self, idx, child):
106
+ from .layout import Spacer
107
+ if isinstance(child, MenuBar):
108
+ self.ui.setMenuBar(child.outer)
109
+ elif isinstance(child, Spacer):
110
+ self.layout.insertItem(idx, child.outer)
111
+ elif isinstance(child, Modal):
112
+ child.outer.show()
113
+ elif isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
114
+ params = {}
115
+ if not child.layout_weight is None:
116
+ params["stretch"] = child.layout_weight
117
+ self.layout.insertWidget(idx, child.outer, **params)
118
+ elif child.children:
119
+ self.addChild(idx, child.children[0])
120
+
121
+ def removeChild(self, idx, child):
122
+ from .layout import Spacer
123
+ if isinstance(child, MenuBar):
124
+ child.outer.close()
125
+ elif isinstance(child, Spacer):
126
+ self.layout.removeItem(child.outer)
127
+ elif isinstance(child, Modal):
128
+ child.outer.close()
129
+ elif isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
130
+ child.outer.setParent(None)
131
+ elif child.children:
132
+ self.removeChild(idx, child.children[0])
@@ -0,0 +1,17 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class ProgressBar(QtBaseWidget):
5
+ def __init__(self, progress, maximum=1):
6
+ super().__init__()
7
+ self.progress = progress*100
8
+ self.maximum = maximum*100
9
+
10
+ def update(self, prev):
11
+ if prev and prev.ui:
12
+ self.ui = prev.ui
13
+ else:
14
+ self.ui = QtWidgets.QProgressBar()
15
+ self.ui.setMaximum(self.maximum)
16
+ self.ui.setValue(int(self.progress))
17
+ super().update(prev)
@@ -0,0 +1,29 @@
1
+ from .. import *
2
+ from .base import *
3
+ from ..utils import *
4
+ from PySide6.QtWidgets import QSizePolicy
5
+
6
+ class RadioButton(QtBaseWidget):
7
+ def __init__(self, text, value, model):
8
+ super().__init__()
9
+ self.text = text
10
+ self.value = value
11
+ self.model = model
12
+
13
+ def update(self, prev):
14
+ if prev and prev.ui:
15
+ self.ui = prev.ui
16
+ try:
17
+ self.ui.clicked.disconnect()
18
+ except:
19
+ pass
20
+ else:
21
+ self.ui = QtWidgets.QRadioButton()
22
+ self.ui.setText(self.text)
23
+ self.ui.setChecked(self.model.value == self.value)
24
+ self.ui.clicked.connect(self._clicked)
25
+ super().update(prev)
26
+
27
+ def _clicked(self):
28
+ self.model.value = self.value
29
+ super()._clicked()