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.
Files changed (104) hide show
  1. PUI/PySide6/__init__.py +49 -0
  2. PUI/PySide6/application.py +58 -0
  3. PUI/PySide6/base.py +285 -0
  4. PUI/PySide6/button.py +21 -0
  5. PUI/PySide6/canvas.py +345 -0
  6. PUI/PySide6/checkbox.py +32 -0
  7. PUI/PySide6/combobox.py +85 -0
  8. PUI/PySide6/dialog.py +72 -0
  9. PUI/PySide6/divider.py +23 -0
  10. PUI/PySide6/image.py +48 -0
  11. PUI/PySide6/label.py +33 -0
  12. PUI/PySide6/layout.py +141 -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 +155 -0
  20. PUI/PySide6/splitter.py +25 -0
  21. PUI/PySide6/tab.py +39 -0
  22. PUI/PySide6/table.py +147 -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 +290 -0
  27. PUI/PySide6/window.py +82 -0
  28. PUI/__init__.py +46 -0
  29. PUI/common.py +26 -0
  30. PUI/decorator.py +20 -0
  31. PUI/dom.py +263 -0
  32. PUI/flet/__init__.py +22 -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/divider.py +14 -0
  39. PUI/flet/label.py +27 -0
  40. PUI/flet/layout.py +50 -0
  41. PUI/flet/progressbar.py +21 -0
  42. PUI/flet/radiobutton.py +27 -0
  43. PUI/flet/scroll.py +83 -0
  44. PUI/flet/tab.py +42 -0
  45. PUI/flet/text.py +55 -0
  46. PUI/flet/textfield.py +58 -0
  47. PUI/flet/window.py +25 -0
  48. PUI/interfaces.py +97 -0
  49. PUI/node.py +432 -0
  50. PUI/state.py +711 -0
  51. PUI/textual/__init__.py +35 -0
  52. PUI/textual/application.py +82 -0
  53. PUI/textual/base.py +148 -0
  54. PUI/textual/button.py +17 -0
  55. PUI/textual/checkbox.py +21 -0
  56. PUI/textual/label.py +36 -0
  57. PUI/textual/layout.py +52 -0
  58. PUI/textual/progressbar.py +17 -0
  59. PUI/textual/radiobutton.py +24 -0
  60. PUI/textual/scroll.py +74 -0
  61. PUI/textual/tab.py +75 -0
  62. PUI/textual/text.py +32 -0
  63. PUI/textual/textfield.py +55 -0
  64. PUI/textual/window.py +7 -0
  65. PUI/timeline.py +36 -0
  66. PUI/tkinter/__init__.py +43 -0
  67. PUI/tkinter/application.py +49 -0
  68. PUI/tkinter/base.py +68 -0
  69. PUI/tkinter/button.py +15 -0
  70. PUI/tkinter/canvas.py +52 -0
  71. PUI/tkinter/checkbox.py +27 -0
  72. PUI/tkinter/label.py +17 -0
  73. PUI/tkinter/layout.py +114 -0
  74. PUI/tkinter/progressbar.py +17 -0
  75. PUI/tkinter/radiobutton.py +26 -0
  76. PUI/tkinter/scroll.py +201 -0
  77. PUI/tkinter/tab.py +52 -0
  78. PUI/tkinter/text.py +20 -0
  79. PUI/tkinter/textfield.py +53 -0
  80. PUI/tkinter/window.py +51 -0
  81. PUI/utils.py +15 -0
  82. PUI/view.py +161 -0
  83. PUI/wx/__init__.py +19 -0
  84. PUI/wx/application.py +44 -0
  85. PUI/wx/base.py +246 -0
  86. PUI/wx/button.py +16 -0
  87. PUI/wx/canvas.py +255 -0
  88. PUI/wx/checkbox.py +25 -0
  89. PUI/wx/combobox.py +81 -0
  90. PUI/wx/dialog.py +66 -0
  91. PUI/wx/divider.py +19 -0
  92. PUI/wx/label.py +18 -0
  93. PUI/wx/layout.py +52 -0
  94. PUI/wx/progressbar.py +19 -0
  95. PUI/wx/radiobutton.py +27 -0
  96. PUI/wx/scroll.py +55 -0
  97. PUI/wx/text.py +23 -0
  98. PUI/wx/textfield.py +66 -0
  99. PUI/wx/window.py +64 -0
  100. qpuiq-0.23.dist-info/LICENSE.txt +21 -0
  101. qpuiq-0.23.dist-info/METADATA +234 -0
  102. qpuiq-0.23.dist-info/RECORD +104 -0
  103. qpuiq-0.23.dist-info/WHEEL +5 -0
  104. qpuiq-0.23.dist-info/top_level.txt +1 -0
PUI/PySide6/layout.py ADDED
@@ -0,0 +1,141 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class Stack(QtBaseLayout):
5
+ pui_terminal = False
6
+ pui_reversed_order = True
7
+
8
+ def __init__(self):
9
+ super().__init__()
10
+ self.qt_params = {}
11
+ if not isinstance(self.non_virtual_parent, QtBaseLayout):
12
+ self.layout_padding = (11,11,11,11)
13
+
14
+ @property
15
+ def outer(self):
16
+ return self.ui
17
+
18
+ @property
19
+ def inner(self):
20
+ return self.layout
21
+
22
+ def destroy(self, direct):
23
+ self.layout = None
24
+ super().destroy(direct)
25
+
26
+ def update(self, prev=None):
27
+ if prev and prev.ui:
28
+ self.ui = prev.ui
29
+ self.qtlayout = prev.qtlayout
30
+ else:
31
+ self.ui = QtWidgets.QWidget()
32
+ self.qtlayout = QtWidgets.QStackedLayout()
33
+ self.qtlayout.setStackingMode(QtWidgets.QStackedLayout.StackAll)
34
+ self.qtlayout.setContentsMargins(0,0,0,0)
35
+ self.ui.setLayout(self.qtlayout)
36
+ super().update(prev)
37
+
38
+ def addChild(self, idx, child):
39
+ from .modal import Modal
40
+ from .layout import Spacer
41
+ if isinstance(child, Spacer):
42
+ pass
43
+ elif isinstance(child, Modal):
44
+ pass
45
+ elif isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
46
+ self.qtlayout.insertWidget(idx, child.outer)
47
+ self.mounted_children.insert(idx, child)
48
+
49
+ def removeChild(self, idx, child):
50
+ from .modal import Modal
51
+ from .layout import Spacer
52
+ if isinstance(child, Spacer):
53
+ pass
54
+ elif isinstance(child, Modal):
55
+ pass
56
+ elif isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
57
+ child.outer.setParent(None)
58
+ self.mounted_children.pop(idx)
59
+
60
+ def postUpdate(self):
61
+ if self.ui:
62
+ if self._onDropped:
63
+ self.ui.setAcceptDrops(True)
64
+ self.ui.installEventFilter(self.eventFilter)
65
+ else:
66
+ self.ui.setAcceptDrops(False)
67
+
68
+ super().postUpdate()
69
+
70
+ class HBox(QtBaseLayout):
71
+ container_x = True
72
+ def update(self, prev):
73
+ if prev and prev.ui:
74
+ self.ui = prev.ui
75
+ self.qtlayout = prev.qtlayout
76
+ else:
77
+ self.ui = QtWidgets.QWidget()
78
+ self.qtlayout = QtWidgets.QHBoxLayout()
79
+ self.qtlayout.setContentsMargins(0,0,0,0)
80
+ self.ui.setLayout(self.qtlayout)
81
+ super().update(prev)
82
+
83
+ class VBox(QtBaseLayout):
84
+ container_y = True
85
+ def update(self, prev):
86
+ if prev and prev.ui:
87
+ self.ui = prev.ui
88
+ self.qtlayout = prev.qtlayout
89
+ else:
90
+ self.ui = QtWidgets.QWidget()
91
+ self.qtlayout = QtWidgets.QVBoxLayout()
92
+ self.qtlayout.setContentsMargins(0,0,0,0)
93
+ self.ui.setLayout(self.qtlayout)
94
+ super().update(prev)
95
+
96
+ class Spacer(PUINode):
97
+ pui_terminal = True
98
+ pui_movable = False
99
+
100
+ def update(self, prev):
101
+ if prev and prev.ui:
102
+ self.ui = prev.ui
103
+ else:
104
+ if isinstance(self.non_virtual_parent, VBox):
105
+ self.ui = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
106
+ elif isinstance(self.non_virtual_parent, HBox):
107
+ self.ui = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
108
+ else:
109
+ self.ui = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
110
+ super().update(prev)
111
+
112
+ def destroy(self, direct):
113
+ # self.ui.deleteLater() # QSpacerItem doesn't have .deleteLater()
114
+ self.ui = None
115
+ super().destroy(direct)
116
+
117
+ class Grid(QtBaseLayout):
118
+ pui_grid_layout = True
119
+
120
+ def update(self, prev):
121
+ if prev and prev.ui:
122
+ self.ui = prev.ui
123
+ self.layout = prev.layout
124
+ else:
125
+ self.ui = QtWidgets.QWidget()
126
+ self.layout = QtWidgets.QGridLayout()
127
+ self.layout.setContentsMargins(0,0,0,0)
128
+ self.ui.setLayout(self.layout)
129
+ super().update(prev)
130
+
131
+ def addChild(self, idx, child):
132
+ if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
133
+ self.layout.addWidget(child.outer, child.grid_row, child.grid_column, child.grid_rowspan or 1, child.grid_columnspan or 1)
134
+ elif child.children:
135
+ self.addChild(idx, child.children[0])
136
+
137
+ def removeChild(self, idx, child):
138
+ if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
139
+ child.outer.setParent(None)
140
+ elif child.children:
141
+ 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()
PUI/PySide6/scroll.py ADDED
@@ -0,0 +1,155 @@
1
+ from .. import *
2
+ from .base import *
3
+ from PySide6.QtWidgets import QSizePolicy
4
+ import math
5
+
6
+ class Scroll(QtBaseWidget):
7
+ pui_terminal = False
8
+ END = -0.0
9
+
10
+ def __init__(self, vertical=None, horizontal=False):
11
+ self.vertical = vertical
12
+ self.horizontal = horizontal
13
+ self.align_x = 0
14
+ self.align_y = 0
15
+ super().__init__()
16
+
17
+ def update(self, prev):
18
+ if prev and prev.ui:
19
+ self.ui = prev.ui
20
+ self.align_x = prev.align_x
21
+ self.align_y = prev.align_y
22
+ if prev.vsb_conn:
23
+ vsb = self.ui.verticalScrollBar()
24
+ vsb.valueChanged.disconnect(prev.vsb_conn)
25
+ vsb.rangeChanged.disconnect(prev.vsb_range_conn)
26
+ if prev.hsb_conn:
27
+ hsb = self.ui.horizontalScrollBar()
28
+ hsb.valueChanged.disconnect(prev.hsb_conn)
29
+ hsb.rangeChanged.disconnect(prev.hsb_range_conn)
30
+ else:
31
+ self.ui = QtWidgets.QScrollArea()
32
+ self.ui.setWidgetResizable(True)
33
+ if self.vertical is None:
34
+ self.ui.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
35
+ elif self.vertical:
36
+ self.ui.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
37
+ else:
38
+ self.ui.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
39
+ if self.horizontal is None:
40
+ self.ui.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
41
+ elif self.horizontal:
42
+ self.ui.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
43
+ else:
44
+ self.ui.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
45
+ vsb = self.ui.verticalScrollBar()
46
+ self.vsb_conn = vsb.valueChanged.connect(self.vsb_changed)
47
+ self.vsb_range_conn = vsb.rangeChanged.connect(self.vsb_range_changed)
48
+ hsb = self.ui.horizontalScrollBar()
49
+ self.hsb_conn = hsb.valueChanged.connect(self.hsb_changed)
50
+ self.hsb_range_conn = hsb.rangeChanged.connect(self.hsb_range_changed)
51
+ super().update(prev)
52
+
53
+ def addChild(self, idx, child):
54
+ if idx != 0:
55
+ return
56
+ if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
57
+ self.ui.setWidget(child.outer)
58
+ if not hasattr(child.outer, "origResizeEvent"):
59
+ child.outer.origResizeEvent = child.outer.resizeEvent
60
+ child.outer.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred))
61
+ child.outer.resizeEvent = self.onUiResized
62
+ elif child.children:
63
+ self.addChild(idx, child.children[0])
64
+
65
+ def removeChild(self, idx, child):
66
+ if idx != 0:
67
+ return
68
+ if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
69
+ child.outer.setParent(None)
70
+ elif child.children:
71
+ self.removeChild(idx, child.children[0])
72
+
73
+ def onUiResized(self, event):
74
+ node = self.get_node()
75
+ if node.destroyed:
76
+ return
77
+ node.children[0].outer.origResizeEvent(event)
78
+ if node.horizontal is False:
79
+ if isinstance(node.children[0], QtBaseLayout):
80
+ node.outer.setMinimumWidth(node.children[0].outer.sizeHint().width())
81
+ elif isinstance(node.children[0], QtBaseWidget):
82
+ node.outer.setMinimumWidth(node.children[0].outer.sizeHint().width())
83
+
84
+ if node.vertical is False:
85
+ if isinstance(node.children[0], QtBaseLayout):
86
+ node.outer.setMinimumHeight(node.children[0].outer.sizeHint().height())
87
+ elif isinstance(node.children[0], QtBaseWidget):
88
+ node.outer.setMinimumHeight(node.children[0].outer.sizeHint().height())
89
+
90
+ def postSync(self):
91
+ self.children[0].outer.resizeEvent = self.onUiResized
92
+
93
+ def scrollX(self, pos=0):
94
+ if math.copysign(1, pos) >= 0:
95
+ self.align_x = 0
96
+ self.hsb_offset = pos
97
+ else:
98
+ self.align_x = 1
99
+ self.hsb_offset = abs(pos)
100
+ return self
101
+
102
+ def scrollY(self, pos=0):
103
+ if math.copysign(1, pos) >= 0:
104
+ self.align_y = 0
105
+ self.vsb_offset = pos
106
+ else:
107
+ self.align_y = 1
108
+ self.vsb_offset = abs(pos)
109
+ return self
110
+
111
+ def hsb_changed(self, *args, **kwargs):
112
+ hsb = self.ui.horizontalScrollBar()
113
+ v = hsb.value()
114
+ if v < 10 and v > hsb.maximum() - 10:
115
+ pass
116
+ elif v < 10:
117
+ self.align_x = 0
118
+ elif v > hsb.maximum() - 10:
119
+ self.align_x = 1
120
+
121
+ def vsb_changed(self, *args, **kwargs):
122
+ vsb = self.ui.verticalScrollBar()
123
+ v = vsb.value()
124
+ if v < 10 and v > vsb.maximum() - 10:
125
+ pass
126
+ elif v < 10:
127
+ self.align_y = 0
128
+ elif v > vsb.maximum() - 10:
129
+ self.align_y = 1
130
+
131
+ def preSync(self):
132
+ hsb = self.ui.horizontalScrollBar()
133
+ if self.align_x == 0:
134
+ self.hsb_offset = hsb.value()
135
+ else:
136
+ self.hsb_offset = hsb.maximum() - hsb.value()
137
+ vsb = self.ui.verticalScrollBar()
138
+ if self.align_y == 0:
139
+ self.vsb_offset = vsb.value()
140
+ else:
141
+ self.vsb_offset = vsb.maximum() - vsb.value()
142
+
143
+ def vsb_range_changed(self, min, max):
144
+ vsb = self.ui.verticalScrollBar()
145
+ if self.align_y == 0:
146
+ vsb.setValue(self.vsb_offset)
147
+ else:
148
+ vsb.setValue(max - self.vsb_offset)
149
+
150
+ def hsb_range_changed(self, min, max):
151
+ hsb = self.ui.verticalScrollBar()
152
+ if self.align_y == 0:
153
+ hsb.setValue(self.hsb_offset)
154
+ else:
155
+ hsb.setValue(max - self.hsb_offset)
@@ -0,0 +1,25 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class Splitter(QtBaseWidget):
5
+ pui_terminal = False
6
+ def __init__(self, vertical=False):
7
+ super().__init__()
8
+ self.vertical = vertical
9
+
10
+ def update(self, prev):
11
+ if prev and prev.ui:
12
+ self.ui = prev.ui
13
+ else:
14
+ self.ui = QtWidgets.QSplitter()
15
+ self.ui.setOrientation(QtCore.Qt.Orientation.Vertical if self.vertical else QtCore.Qt.Orientation.Horizontal)
16
+ super().update(prev)
17
+
18
+ def addChild(self, idx, child):
19
+ if isinstance(child, QtBaseWidget) or isinstance(child, QtBaseLayout):
20
+ self.ui.insertWidget(idx, child.outer)
21
+ else:
22
+ self.addChild(idx, child.children[0])
23
+
24
+ def removeChild(self, idx, child):
25
+ child.outer.setParent(None)
PUI/PySide6/tab.py ADDED
@@ -0,0 +1,39 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class Tabs(QtBaseWidget):
5
+ NORTH = "n"
6
+ SOUTH = "s"
7
+ EAST = "e"
8
+ WEST = "w"
9
+ pui_terminal = False
10
+ def __init__(self, tabposition=NORTH):
11
+ super().__init__()
12
+ self.tabposition = tabposition
13
+
14
+ def update(self, prev):
15
+ if prev and prev.ui:
16
+ self.ui = prev.ui
17
+ else:
18
+ self.ui = QtWidgets.QTabWidget()
19
+ super().update(prev)
20
+
21
+ def addChild(self, idx, child):
22
+ parent = child.parent
23
+ while not isinstance(parent, Tab):
24
+ parent = parent.parent
25
+ self.ui.insertTab(idx, child.outer, parent.label)
26
+
27
+ def removeChild(self, idx, child):
28
+ self.ui.removeTab(idx)
29
+
30
+ def postSync(self):
31
+ for i,c in enumerate(self.children):
32
+ self.ui.setTabText(i, c.label)
33
+
34
+
35
+ class Tab(PUINode):
36
+ pui_virtual = True
37
+ def __init__(self, label):
38
+ super().__init__()
39
+ self.label = label