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/wx/canvas.py ADDED
@@ -0,0 +1,255 @@
1
+ from .. import *
2
+ from .base import *
3
+ import math
4
+
5
+ class Canvas(WxBaseWidget):
6
+ weak_expand_x = True
7
+ weak_expand_y = True
8
+
9
+ def __init__(self, painter, *args):
10
+ super().__init__()
11
+ self.ui = None
12
+ self.painter = painter
13
+ self.args = args
14
+
15
+ def update(self, prev):
16
+ if prev and prev.ui:
17
+ self.ui = prev.ui
18
+ self.ui.Refresh()
19
+ else:
20
+ self.ui = wx.Panel(getWindow(self.parent))
21
+ self.ui.Bind(wx.EVT_PAINT, self._paint)
22
+ self.ui.Bind(wx.EVT_LEFT_DCLICK, self._LeftDblClick)
23
+ self.ui.Bind(wx.EVT_LEFT_DOWN, self._LeftDown)
24
+ self.ui.Bind(wx.EVT_LEFT_UP, self._LeftUp)
25
+ self.ui.Bind(wx.EVT_MOTION, self._Motion)
26
+ self.ui.Bind(wx.EVT_MOUSEWHEEL, self._MouseWheel)
27
+ self.ui.SetMinSize((self.layout_width, self.layout_height))
28
+
29
+ super().update(prev)
30
+
31
+ def _MouseWheel(self, event):
32
+ e = PUIEvent()
33
+ e.x, e.y = event.GetPosition()
34
+ if event.GetWheelAxis() == wx.MOUSE_WHEEL_VERTICAL:
35
+ e.h_delta = 0
36
+ e.v_delta = event.GetWheelRotation()
37
+ e.x_delta = 0
38
+ e.y_delta = event.GetWheelDelta()
39
+ else:
40
+ e.h_delta = event.GetWheelRotation()
41
+ e.v_delta = 0
42
+ e.x_delta = event.GetWheelDelta()
43
+ e.y_delta = 0
44
+ self.get_node()._wheel(e)
45
+
46
+ def _LeftDblClick(self, event):
47
+ e = PUIEvent()
48
+ e.x, e.y = event.GetPosition()
49
+ self.get_node()._dblclicked(e)
50
+
51
+ def _LeftDown(self, event):
52
+ e = PUIEvent()
53
+ e.x, e.y = event.GetPosition()
54
+ self.get_node()._mousedown(e)
55
+
56
+ def _LeftUp(self, event):
57
+ e = PUIEvent()
58
+ e.x, e.y = event.GetPosition()
59
+ self.get_node()._mouseup(e)
60
+
61
+ def _Motion(self, event):
62
+ e = PUIEvent()
63
+ e.x, e.y = event.GetPosition()
64
+ self.get_node()._mousemove(e)
65
+
66
+ def _paint(self, event):
67
+ node = self.get_node()
68
+
69
+ node.dc = wx.PaintDC(node.ui)
70
+ if not node.style_bgcolor is None:
71
+ original_brush = node.dc.GetBrush()
72
+ node.dc.SetBrush(wx.Brush(int_to_wx_colour(node.style_bgcolor)))
73
+ node.dc.DrawRectangle(self.ui.GetClientRect())
74
+ node.dc.SetBrush(original_brush)
75
+
76
+ node.painter(node, *node.args)
77
+ node.dc = None
78
+
79
+
80
+ def drawText(self, x, y, text, w=None, h=None, size=12, color=None, rotate=0, anchor=Anchor.LEFT_TOP):
81
+ original_pen = self.dc.GetPen()
82
+ original_brush = self.dc.GetBrush()
83
+
84
+ lines = text.split("\n")
85
+ extents = [self.dc.GetTextExtent(l) for l in lines]
86
+ width = max([e[0] for e in extents])
87
+ height = sum([e[1] for e in extents])
88
+
89
+ dx = 0
90
+ dy = 0
91
+ if anchor.value[0]=="center":
92
+ dx = width/2
93
+ elif anchor.value[0]=="right":
94
+ dx = width
95
+
96
+ if anchor.value[1]=="center":
97
+ dy = height/2
98
+ elif anchor.value[1]=="bottom":
99
+ dy = height
100
+
101
+ gc = wx.GraphicsContext.Create(self.dc)
102
+
103
+ gc.PushState()
104
+
105
+ gc.Translate(x+dx, y+dy)
106
+ gc.Rotate(math.radians(rotate))
107
+ gc.Translate(-dx, -dy)
108
+
109
+ if color is None:
110
+ color = self.ui.GetForegroundColour()
111
+ else:
112
+ color = int_to_wx_colour(color)
113
+
114
+ gc.SetFont(wx.Font(size, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL), color)
115
+ y_off = 0
116
+ for i,line in enumerate(lines):
117
+ gc.PushState()
118
+ gc.DrawText(line, 0, y_off)
119
+ gc.PopState()
120
+ y_off += extents[i][1]
121
+
122
+ gc.PopState()
123
+
124
+ self.dc.SetPen(original_pen)
125
+ self.dc.SetBrush(original_brush)
126
+
127
+ def drawLine(self, x1, y1, x2, y2, color=0, width=1):
128
+ original_pen = self.dc.GetPen()
129
+ original_brush = self.dc.GetBrush()
130
+
131
+ self.dc.SetPen(wx.Pen(int_to_wx_colour(color), width))
132
+ self.dc.DrawLine(int(x1), int(y1), int(x2), int(y2))
133
+ self.dc.SetPen(original_pen)
134
+ self.dc.SetBrush(original_brush)
135
+
136
+ def drawPolyline(self, coords, color=0, width=1):
137
+ original_pen = self.dc.GetPen()
138
+ original_brush = self.dc.GetBrush()
139
+
140
+ if color is not None:
141
+ self.dc.SetPen(wx.Pen(int_to_wx_colour(color), width))
142
+
143
+ coords = [(int(c[0]), int(c[1])) for c in coords]
144
+ self.dc.DrawLines(coords)
145
+
146
+ self.dc.SetPen(original_pen)
147
+ self.dc.SetBrush(original_brush)
148
+
149
+ def drawPolygon(self, coords, fill=None, stroke=None, width=1):
150
+ original_pen = self.dc.GetPen()
151
+ original_brush = self.dc.GetBrush()
152
+
153
+ if fill is None:
154
+ self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
155
+ else:
156
+ self.dc.SetBrush(wx.Brush(int_to_wx_colour(fill)))
157
+ if stroke is None:
158
+ self.dc.SetPen(wx.NullPen)
159
+ else:
160
+ self.dc.SetPen(wx.Pen(int_to_wx_colour(stroke), width))
161
+
162
+ coords = [(int(c[0]), int(c[1])) for c in coords]
163
+ self.dc.DrawPolygon(coords)
164
+ self.dc.SetPen(original_pen)
165
+ self.dc.SetBrush(original_brush)
166
+
167
+ def drawRect(self, x1, y1, x2, y2, fill=None, stroke=None, width=1):
168
+ original_pen = self.dc.GetPen()
169
+ original_brush = self.dc.GetBrush()
170
+
171
+ if fill is None:
172
+ self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
173
+ else:
174
+ self.dc.SetBrush(wx.Brush(int_to_wx_colour(fill)))
175
+ if stroke is None:
176
+ self.dc.SetPen(wx.NullPen)
177
+ else:
178
+ self.dc.SetPen(wx.Pen(int_to_wx_colour(stroke), width))
179
+
180
+ x = min(x1, x1)
181
+ y = min(y1, y2)
182
+ w = abs(x2 - x1)
183
+ h = abs(y2 - y1)
184
+
185
+ self.dc.DrawRectangle(int(x), int(y), int(w), int(h))
186
+ self.dc.SetPen(original_pen)
187
+ self.dc.SetBrush(original_brush)
188
+
189
+ def drawEllipse(self, x, y, rx, ry, fill=None, stroke=None, width=1):
190
+ original_pen = self.dc.GetPen()
191
+ original_brush = self.dc.GetBrush()
192
+
193
+ if fill is None:
194
+ self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
195
+ else:
196
+ self.dc.SetBrush(wx.Brush(int_to_wx_colour(fill)))
197
+ if stroke is None:
198
+ self.dc.SetPen(wx.NullPen)
199
+ else:
200
+ self.dc.SetPen(wx.Pen(int_to_wx_colour(stroke), width))
201
+
202
+ self.dc.DrawEllipse(int(x-rx), int(y-ry), int(rx*2), int(ry*2))
203
+ self.dc.SetPen(original_pen)
204
+ self.dc.SetBrush(original_brush)
205
+
206
+ def drawShapely(self, shape, fill=None, stroke=None, width=1):
207
+ original_pen = self.dc.GetPen()
208
+ original_brush = self.dc.GetBrush()
209
+
210
+ if fill is None:
211
+ self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
212
+ else:
213
+ self.dc.SetBrush(wx.Brush(int_to_wx_colour(fill)))
214
+ if stroke is None:
215
+ self.dc.SetPen(wx.NullPen)
216
+ else:
217
+ self.dc.SetPen(wx.Pen(int_to_wx_colour(stroke), width))
218
+
219
+ self._drawShapely(shape, fill, stroke, width)
220
+
221
+ def _drawShapely(self, shape, fill=None, stroke=None, width=1):
222
+ if hasattr(shape, "geoms"):
223
+ for g in shape.geoms:
224
+ self.drawShapely(g, fill, stroke, width)
225
+ elif hasattr(shape, "exterior"): # polygon
226
+ gc = wx.GraphicsContext.Create(self.dc)
227
+ if gc:
228
+ path = gc.CreatePath()
229
+
230
+ exterior = shape.exterior.coords
231
+ path.MoveToPoint(* exterior[0])
232
+ for point in exterior[1:]:
233
+ path.AddLineToPoint(*point)
234
+ path.CloseSubpath()
235
+
236
+ for hole in shape.interiors:
237
+ hole = hole.coords
238
+ path.MoveToPoint(*hole[0])
239
+ # Draw holes in reverse order
240
+ for point in hole[1:]:
241
+ path.AddLineToPoint(*point)
242
+ path.CloseSubpath()
243
+
244
+ if fill is not None:
245
+ gc.SetBrush(wx.Brush(int_to_wx_colour(fill)))
246
+ if stroke is not None:
247
+ gc.SetPen(wx.Pen(int_to_wx_colour(stroke), width))
248
+
249
+ gc.DrawPath(path)
250
+ elif hasattr(shape, "x") and hasattr(shape, "y"): # point
251
+ self.drawEllipse(shape.x, shape.y, width/2, width/2, fill=stroke)
252
+ elif hasattr(shape, "coords"): # linestring, linearring
253
+ self.drawPolyline(shape.coords, color=stroke, width=width)
254
+ else:
255
+ raise RuntimeError(f"Not implemented: drawShapely({type(shape).__name__}) {dir(shape)}")
PUI/wx/checkbox.py ADDED
@@ -0,0 +1,25 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class Checkbox(WxBaseWidget):
5
+ def __init__(self, text, model):
6
+ super().__init__()
7
+ self.text = text
8
+ self.model = model
9
+
10
+ def update(self, prev):
11
+ if prev and prev.ui:
12
+ self.ui = prev.ui
13
+ self.ui.SetLabel(self.text)
14
+ else:
15
+ self.ui = wx.CheckBox(getWindow(self.parent), label=self.text)
16
+ self.ui.Bind(wx.EVT_CHECKBOX, self._checked)
17
+
18
+ self.ui.SetValue(self.model.value)
19
+
20
+ super().update(prev)
21
+
22
+ def _checked(self, *args, **kwargs):
23
+ node = self.get_node()
24
+ node.model.value = node.ui.GetValue()
25
+ node._clicked()
PUI/wx/combobox.py ADDED
@@ -0,0 +1,72 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class ComboBox(WxBaseWidget):
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.ui = prev.ui
17
+ else:
18
+ self.curr_index = Prop()
19
+ self.curr_text = Prop()
20
+ self.ui = wx.ComboBox(getWindow(self.parent), choices=[])
21
+ self.ui.Bind(wx.EVT_COMBOBOX, self._combobox)
22
+ self.ui.Bind(wx.EVT_TEXT, self._text)
23
+
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.curr_index.set(index):
38
+ self.ui.SetSelection(index)
39
+
40
+ if self.curr_text.set(text):
41
+ self.ui.SetValue(text)
42
+
43
+ def _combobox(self, *args, **kwargs):
44
+ node = self.get_node()
45
+ idx = self.ui.GetSelection()
46
+ if node.index_model:
47
+ node.index_model.value = idx
48
+ e = PUIEvent()
49
+ e.value = idx
50
+ node._change(e)
51
+
52
+ def _text(self, *args, **kwargs):
53
+ node = self.get_node()
54
+ text = self.ui.GetValue()
55
+ if node.text_model:
56
+ node.text_model.value = text
57
+ e = PUIEvent()
58
+ e.value = text
59
+ node._change(e)
60
+
61
+ def addChild(self, idx, child):
62
+ self.ui.Insert(child.text, idx)
63
+
64
+ def removeChild(self, idx, child):
65
+ self.ui.Delete(idx)
66
+
67
+
68
+ class ComboBoxItem(PUINode):
69
+ def __init__(self, text):
70
+ super().__init__()
71
+ self.id(text)
72
+ self.text = text
PUI/wx/dialog.py ADDED
@@ -0,0 +1,66 @@
1
+ from .base import wx
2
+
3
+ def OpenDirectory(title="Open Directory", directory=""):
4
+ with wx.DirDialog(None, title, directory, wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST) as dir_dialog:
5
+ if dir_dialog.ShowModal() == wx.ID_CANCEL:
6
+ return None
7
+ return dir_dialog.GetPath()
8
+
9
+ def OpenFile(title="Open File", directory="", types=None):
10
+ if types:
11
+ types = types.replace(";;", "|")
12
+ if types is None:
13
+ types = wx.FileSelectorDefaultWildcardStr
14
+ with wx.FileDialog(None, title, directory, wildcard=types,
15
+ style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as file_dialog:
16
+ if file_dialog.ShowModal() == wx.ID_CANCEL:
17
+ return None
18
+ return file_dialog.GetPath()
19
+
20
+ def OpenFiles(title="Open Files", directory="", types=None):
21
+ if types:
22
+ types = types.replace(";;", "|")
23
+ if types is None:
24
+ types = wx.FileSelectorDefaultWildcardStr
25
+ with wx.FileDialog(None, title, directory, wildcard=types,
26
+ style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) as file_dialog:
27
+ if file_dialog.ShowModal() == wx.ID_CANCEL:
28
+ return None
29
+ return file_dialog.GetPaths()
30
+
31
+ def SaveFile(default, title="Save File", directory="", types=None):
32
+ if types:
33
+ types = types.replace(";;", "|")
34
+ if types is None:
35
+ types = wx.FileSelectorDefaultWildcardStr
36
+ if not directory and isinstance(default, str):
37
+ directory = default
38
+ with wx.FileDialog(None, title, directory, wildcard=types,
39
+ style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as file_dialog:
40
+ if file_dialog.ShowModal() == wx.ID_CANCEL:
41
+ return None
42
+ return file_dialog.GetPath()
43
+
44
+ def Information(message="Information", title="Information Dialog"):
45
+ wx.MessageBox(message, title, wx.OK | wx.ICON_INFORMATION)
46
+
47
+ def Warning(message="Warning", title="Warning Dialog"):
48
+ wx.MessageBox(message, title, wx.OK | wx.ICON_WARNING)
49
+
50
+ def Critical(message="Critical", title="Critical Dialog"):
51
+ wx.MessageBox(message, title, wx.OK | wx.ICON_ERROR)
52
+
53
+ def Confirm(message="Confirm", title="Confirm Dialog"):
54
+ dlg = wx.MessageDialog(None, message, title, wx.YES_NO | wx.ICON_QUESTION)
55
+ result = dlg.ShowModal()
56
+ dlg.Destroy()
57
+ return result == wx.ID_YES
58
+
59
+ def Prompt(prompt="Input", title="Input Dialog", default=""):
60
+ dlg = wx.TextEntryDialog(None, prompt, title, default)
61
+ if dlg.ShowModal() == wx.ID_OK:
62
+ result = dlg.GetValue()
63
+ else:
64
+ result = None
65
+ dlg.Destroy()
66
+ return result
PUI/wx/divider.py ADDED
@@ -0,0 +1,19 @@
1
+ from .. import *
2
+ from .base import *
3
+ from .layout import *
4
+
5
+ class Divider(WxBaseWidget):
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
+ if isinstance(self.non_virtual_parent, VBox):
14
+ style = wx.LI_HORIZONTAL
15
+ else:
16
+ style = wx.LI_VERTICAL
17
+ self.ui = wx.StaticLine(getWindow(self.parent), style=style, size=(15, 15))
18
+
19
+ super().update(prev)
PUI/wx/label.py ADDED
@@ -0,0 +1,18 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class Label(WxBaseWidget):
5
+ def __init__(self, text, selectable=False):
6
+ super().__init__()
7
+ self.text = text
8
+ self.selectable = selectable
9
+
10
+ def update(self, prev):
11
+ if prev and prev.ui:
12
+ self.ui = prev.ui
13
+ self.ui.SetLabel(self.text)
14
+ else:
15
+ self.ui = wx.StaticText(getWindow(self.parent), label=self.text)
16
+ self.ui.Bind(wx.EVT_LEFT_DOWN, self._clicked)
17
+
18
+ super().update(prev)
PUI/wx/layout.py ADDED
@@ -0,0 +1,46 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class HBox(WxBaseLayout):
5
+ container_x = True
6
+ def update(self, prev):
7
+ if prev and prev.ui:
8
+ self.ui = prev.ui
9
+ else:
10
+ self.ui = wx.BoxSizer(wx.HORIZONTAL)
11
+ super().update(prev)
12
+
13
+ class VBox(WxBaseLayout):
14
+ container_y = True
15
+ def update(self, prev):
16
+ if prev and prev.ui:
17
+ self.ui = prev.ui
18
+ else:
19
+ self.ui = wx.BoxSizer(wx.VERTICAL)
20
+ super().update(prev)
21
+
22
+ class Spacer(WXBase):
23
+ pui_terminal = True
24
+ def __init__(self):
25
+ super().__init__()
26
+ self.layout_weight = 1
27
+
28
+ class Grid(WxBaseLayout):
29
+ pui_grid_layout = True
30
+ def update(self, prev):
31
+ if prev and prev.ui:
32
+ self.ui = prev.ui
33
+ else:
34
+ self.ui = wx.GridBagSizer()
35
+ super().update(prev)
36
+
37
+ def addChild(self, idx, child):
38
+ if isinstance(child, WxBaseLayout) or isinstance(child, WxBaseWidget):
39
+ p = 0
40
+ if child.layout_padding:
41
+ p = max(child.layout_padding)
42
+ self.ui.Add(child.outer, pos=(child.grid_row, child.grid_column), span=(child.grid_rowspan or 1, child.grid_columnspan or 1), flag=wx.ALL|wx.EXPAND, border=p)
43
+
44
+ def removeChild(self, idx, child):
45
+ if isinstance(child, WxBaseLayout) or isinstance(child, WxBaseWidget):
46
+ pass
PUI/wx/progressbar.py ADDED
@@ -0,0 +1,17 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class ProgressBar(WxBaseWidget):
5
+ def __init__(self, progress, maximum=1):
6
+ super().__init__()
7
+ self.progress = progress
8
+ self.maximum = maximum
9
+
10
+ def update(self, prev):
11
+ if prev and prev.ui:
12
+ self.ui = prev.ui
13
+ else:
14
+ self.ui = wx.Gauge(getWindow(self.parent))
15
+ self.ui.SetRange(self.maximum)
16
+ self.ui.SetValue(self.progress)
17
+ super().update(prev)
PUI/wx/radiobutton.py ADDED
@@ -0,0 +1,27 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class RadioButton(WxBaseWidget):
5
+ def __init__(self, text, value, model):
6
+ super().__init__()
7
+ self.var = None
8
+ self.text = text
9
+ self.value = value
10
+ self.model = model
11
+
12
+ def update(self, prev):
13
+ if prev and prev.ui:
14
+ self.ui = prev.ui
15
+ self.ui.SetLabel(self.text)
16
+ else:
17
+ self.ui = wx.RadioButton(getWindow(self.parent), label=self.text, style=wx.RB_SINGLE)
18
+ self.ui.Bind(wx.EVT_RADIOBUTTON, self._selected)
19
+
20
+ self.ui.SetValue(self.model.value == self.value)
21
+
22
+ super().update(prev)
23
+
24
+ def _selected(self, *args, **kwargs):
25
+ node = self.get_node()
26
+ node.model.value = node.value
27
+ node._clicked()
PUI/wx/scroll.py ADDED
@@ -0,0 +1,44 @@
1
+ from .. import *
2
+ from .base import *
3
+ import wx.lib.scrolledpanel as scrolled
4
+
5
+ class Scroll(WxBaseWidget):
6
+ pui_terminal = False
7
+ weak_expand_x = True
8
+ weak_expand_y = True
9
+ scroll = True
10
+
11
+ END = -0.0
12
+
13
+ def __init__(self, vertical=None, horizontal=False):
14
+ self.vertical = vertical
15
+ self.horizontal = horizontal
16
+ super().__init__()
17
+
18
+ def update(self, prev):
19
+ if prev and prev.ui:
20
+ self.ui = prev.ui
21
+ else:
22
+ self.ui = scrolled.ScrolledPanel(getWindow(self.parent))
23
+ super().update(prev)
24
+
25
+ def addChild(self, idx, child):
26
+ if isinstance(child, WxBaseLayout):
27
+ self.ui.SetSizer(child.outer)
28
+ elif isinstance(child, WxBaseWidget):
29
+ pass
30
+
31
+ def removeChild(self, idx, child):
32
+ if isinstance(child, WxBaseLayout):
33
+ pass
34
+ elif isinstance(child, WxBaseWidget):
35
+ pass
36
+
37
+ def scrollX(self, pos=0):
38
+ return self
39
+
40
+ def scrollY(self, pos=0):
41
+ return self
42
+
43
+ def postSync(self):
44
+ self.ui.SetupScrolling(scroll_x=self.horizontal or self.horizontal is None, scroll_y=self.vertical or self.vertical is None, scrollToTop=False)
PUI/wx/text.py ADDED
@@ -0,0 +1,23 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class Text(WxBaseWidget):
5
+ def __init__(self, text, selectable=False):
6
+ super().__init__()
7
+ self.text = text
8
+ self.selectable = selectable
9
+
10
+ def update(self, prev):
11
+ if prev and prev.ui:
12
+ self.ui = prev.ui
13
+ self.ui.SetLabel(self.text)
14
+ else:
15
+ self.ui = wx.StaticText(getWindow(self.parent), label=self.text)
16
+
17
+ super().update(prev)
18
+
19
+ class Html(Text):
20
+ pui_supported = False
21
+
22
+ class MarkDown(Text):
23
+ pui_supported = False
PUI/wx/textfield.py ADDED
@@ -0,0 +1,56 @@
1
+ from .. import *
2
+ from .base import *
3
+
4
+ class TextField(WxBaseWidget):
5
+ def __init__(self, model, edit_model=None):
6
+ super().__init__()
7
+ self.model = model
8
+ self.edit_model = edit_model
9
+ self.editing = False
10
+ self.changed_cb = None
11
+ self.layout_width = 50
12
+ self.layout_height = -1
13
+
14
+ def update(self, prev):
15
+ model_value = str(self.model.value)
16
+ if prev and prev.ui:
17
+ self.editing = prev.editing
18
+ self.ui = prev.ui
19
+ self.curr_value = prev.curr_value
20
+ if self.curr_value.set(model_value) and not self.editing:
21
+ self.ui.SetValue(model_value)
22
+ else:
23
+ self.curr_value = Prop(model_value)
24
+ self.ui = wx.TextCtrl(getWindow(self.parent))
25
+ self.ui.SetValue(model_value)
26
+ self.ui.Bind(wx.EVT_TEXT, self.on_textchanged)
27
+ self.ui.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
28
+
29
+ self.ui.SetMinSize((self.layout_width, self.layout_height))
30
+
31
+ if self.edit_model and not self.editing:
32
+ self.edit_model.value = model_value
33
+
34
+ super().update(prev)
35
+
36
+ def on_textchanged(self, *args):
37
+ node = self.get_node()
38
+ node.editing = True
39
+ value = self.ui.GetValue()
40
+ if node.edit_model:
41
+ node.edit_model.value = value
42
+ e = PUIEvent()
43
+ e.value = value
44
+ self._input(e)
45
+
46
+ def on_kill_focus(self, *args):
47
+ node = self.get_node()
48
+ node.editing = True
49
+
50
+ value = self.ui.GetValue()
51
+ node.model.value = value
52
+ if node.edit_model:
53
+ node.edit_model.value = value
54
+ e = PUIEvent()
55
+ e.value = value
56
+ self._change(e)