pygui_simple 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/PKG-INFO +1 -1
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/pyproject.toml +1 -1
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/tkcalendar.py +4 -4
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/tkscrollpicker.py +6 -6
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/tkslideswitch.py +4 -4
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/tkwin.py +33 -44
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/winbasic.py +101 -72
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/LICENSE +0 -0
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/README.md +0 -0
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/__init__.py +0 -0
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/cv2_utilities.py +0 -0
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/py.typed +0 -0
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/tkcontrol.py +0 -0
- {pygui_simple-0.2.0 → pygui_simple-0.3.0}/src/pygui_simple/tkmatplot.py +0 -0
|
@@ -8,7 +8,7 @@ import tkinter as tk
|
|
|
8
8
|
import tkinter.font as tkFont
|
|
9
9
|
from tkinter import ttk
|
|
10
10
|
|
|
11
|
-
from pygui_simple.winbasic import
|
|
11
|
+
from pygui_simple.winbasic import Container
|
|
12
12
|
from pygui_simple.tkcontrol import tkControl
|
|
13
13
|
|
|
14
14
|
|
|
@@ -34,7 +34,7 @@ class CalendarCtrl(tkControl):
|
|
|
34
34
|
_cmb_month: ttk Combobox for month selection
|
|
35
35
|
_items: List of Treeview item IDs for calendar week rows
|
|
36
36
|
"""
|
|
37
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
37
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str, **kwargs: object):
|
|
38
38
|
""" Initialize the calendar control widget.
|
|
39
39
|
|
|
40
40
|
Args:
|
|
@@ -48,7 +48,7 @@ class CalendarCtrl(tkControl):
|
|
|
48
48
|
super().__init__(parent, "", idself, ctrl)
|
|
49
49
|
|
|
50
50
|
self._master: tk.Misc = parent
|
|
51
|
-
self._owner:
|
|
51
|
+
self._owner: Container = owner
|
|
52
52
|
|
|
53
53
|
# first day of week, default to Monday)
|
|
54
54
|
fwday = cast(int, kwargs.get("fwday", 0))
|
|
@@ -429,7 +429,7 @@ class CalendarCtrl(tkControl):
|
|
|
429
429
|
self._canvas.place_forget()
|
|
430
430
|
|
|
431
431
|
|
|
432
|
-
class CalendarDialog(
|
|
432
|
+
class CalendarDialog(Container):
|
|
433
433
|
""" A modal, borderless pop-up dialog for date selection.
|
|
434
434
|
|
|
435
435
|
This class creates a top-level tkinter window containing a CalendarCtrl widget
|
|
@@ -9,7 +9,7 @@ from typing import override, cast
|
|
|
9
9
|
from typing import TypeAlias, Callable, Any
|
|
10
10
|
from typing import Generic, TypeVar
|
|
11
11
|
|
|
12
|
-
from pygui_simple.winbasic import
|
|
12
|
+
from pygui_simple.winbasic import Container
|
|
13
13
|
from pygui_simple.tkcontrol import tkControl
|
|
14
14
|
|
|
15
15
|
|
|
@@ -171,13 +171,13 @@ class ScrollPicker(tk.Frame, Generic[T]):
|
|
|
171
171
|
|
|
172
172
|
|
|
173
173
|
class ScrollPickerCtrl(tkControl, Generic[T]):
|
|
174
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
174
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str,
|
|
175
175
|
width: int, height: int,
|
|
176
176
|
val_list: list[T],
|
|
177
177
|
initial: T | None = None,
|
|
178
178
|
background: str = "white"):
|
|
179
179
|
self._master: tk.Misc = parent
|
|
180
|
-
self._owner:
|
|
180
|
+
self._owner: Container = owner
|
|
181
181
|
|
|
182
182
|
self._frame: tk.Frame = tk.Frame(self._master,
|
|
183
183
|
background=background,
|
|
@@ -355,12 +355,12 @@ class DateScrollPickerDialog:
|
|
|
355
355
|
|
|
356
356
|
|
|
357
357
|
class TimeScrollPickerCtrl(tkControl):
|
|
358
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
358
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str,
|
|
359
359
|
width: int, height: int,
|
|
360
360
|
background: str = "white",
|
|
361
361
|
title: str = "", initial: str = ""):
|
|
362
362
|
self._master: tk.Misc = parent
|
|
363
|
-
self._owner:
|
|
363
|
+
self._owner: Container = owner
|
|
364
364
|
|
|
365
365
|
self._frame: tk.Frame = tk.Frame(self._master,
|
|
366
366
|
background=background,
|
|
@@ -439,7 +439,7 @@ class TimeScrollPickerCtrl(tkControl):
|
|
|
439
439
|
return f"{self._selected_hour:02d}:{self._selected_minute:02d}"
|
|
440
440
|
|
|
441
441
|
|
|
442
|
-
class TimeScrollPickerDialog(
|
|
442
|
+
class TimeScrollPickerDialog(Container):
|
|
443
443
|
def __init__(self, point: tuple[int, int] | None = None,
|
|
444
444
|
title: str = "", initial: str = ""):
|
|
445
445
|
super().__init__(title, 0, 0)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import tkinter as tk
|
|
4
4
|
from typing import Callable, cast, override
|
|
5
5
|
|
|
6
|
-
from pygui_simple.winbasic import
|
|
6
|
+
from pygui_simple.winbasic import Container
|
|
7
7
|
from pygui_simple.tkcontrol import tkControl
|
|
8
8
|
|
|
9
9
|
|
|
@@ -27,7 +27,7 @@ class SlideSwitchCtrl(tkControl):
|
|
|
27
27
|
def __init__(
|
|
28
28
|
self,
|
|
29
29
|
parent: tk.Misc,
|
|
30
|
-
owner:
|
|
30
|
+
owner: Container,
|
|
31
31
|
idself: str,
|
|
32
32
|
width: int = 80,
|
|
33
33
|
height: int = 40,
|
|
@@ -59,7 +59,7 @@ class SlideSwitchCtrl(tkControl):
|
|
|
59
59
|
"""
|
|
60
60
|
ctrl = tk.Canvas(parent, width=width, height=height, highlightthickness=0)
|
|
61
61
|
super().__init__(parent, "", idself, ctrl)
|
|
62
|
-
self._master:
|
|
62
|
+
self._master: Container = owner
|
|
63
63
|
|
|
64
64
|
self._width: int = width
|
|
65
65
|
self._height: int = height
|
|
@@ -364,7 +364,7 @@ class SlideSwitchCtrl(tkControl):
|
|
|
364
364
|
|
|
365
365
|
|
|
366
366
|
if __name__ == "__main__":
|
|
367
|
-
class tkBasic(
|
|
367
|
+
class tkBasic(Container):
|
|
368
368
|
"""Demonstration application for the SlideSwitch widget.
|
|
369
369
|
|
|
370
370
|
Creates a simple Tkinter window with the SlideSwitch widget,
|
|
@@ -40,7 +40,7 @@ IS_WINDOWS = platform.system() == "Windows"
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
class LabelCtrl(tkControl):
|
|
43
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
43
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str,
|
|
44
44
|
text: str, clickable: bool, **options: Any):
|
|
45
45
|
# po(f"{idself}: {options}")
|
|
46
46
|
ctrl = ttk.Label(parent, text=text, **options)
|
|
@@ -103,11 +103,11 @@ class ImagePanelCtrl(tkControl):
|
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
class ButtonCtrl(tkControl):
|
|
106
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
106
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str, text: str,
|
|
107
107
|
**options: Any):
|
|
108
108
|
ctrl = ttk.Button(parent, text=text, **options)
|
|
109
109
|
tkControl.__init__(self, parent, text, idself, ctrl)
|
|
110
|
-
self._owner:
|
|
110
|
+
self._owner: Container = owner
|
|
111
111
|
_ = ctrl.configure(command=self._btn_clicked, **options)
|
|
112
112
|
|
|
113
113
|
def _btn_clicked(self):
|
|
@@ -117,7 +117,7 @@ class ButtonCtrl(tkControl):
|
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
class ImageBtttonCtrl(tkControl):
|
|
120
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
120
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str, *,
|
|
121
121
|
respath: str, imagefile: str, text: str | None,
|
|
122
122
|
width: int = 0, height: int = 0,
|
|
123
123
|
**options: Any):
|
|
@@ -169,7 +169,7 @@ class ImageBtttonCtrl(tkControl):
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
class CheckButtonCtrl(tkControl):
|
|
172
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
172
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str, *,
|
|
173
173
|
text: str, vartext: str, select: bool, **options: Any):
|
|
174
174
|
ctrl = tk.Checkbutton(parent)
|
|
175
175
|
tkControl.__init__(self, parent, "", idself, ctrl)
|
|
@@ -190,7 +190,7 @@ class CheckButtonCtrl(tkControl):
|
|
|
190
190
|
|
|
191
191
|
|
|
192
192
|
class ComboboxCtrl(tkControl):
|
|
193
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
193
|
+
def __init__(self, parent: tk.Misc, owner: Container, *,
|
|
194
194
|
idself: str, default: int, **options: Any):
|
|
195
195
|
ctrl = ttk.Combobox(parent)
|
|
196
196
|
super().__init__(parent, "", idself, ctrl)
|
|
@@ -237,12 +237,12 @@ class ListboxCtrl(tkControl):
|
|
|
237
237
|
|
|
238
238
|
|
|
239
239
|
class RadioButtonCtrl(tkControl):
|
|
240
|
-
def __init__(self, parent: tk.Misc, owner:
|
|
240
|
+
def __init__(self, parent: tk.Misc, owner: Container, idself: str, *,
|
|
241
241
|
text: str, vartext: str, value: int, **options: Any):
|
|
242
242
|
ctrl = ttk.Radiobutton(parent)
|
|
243
243
|
tkControl.__init__(self, parent, "", idself, ctrl)
|
|
244
244
|
# self._app: GuiBasic = app
|
|
245
|
-
self._master:
|
|
245
|
+
self._master: Container = owner
|
|
246
246
|
self._vartext: str = vartext
|
|
247
247
|
if self._vartext not in self._master.__dict__:
|
|
248
248
|
self._master.__dict__[self._vartext] = tk.IntVar()
|
|
@@ -258,7 +258,7 @@ class RadioButtonCtrl(tkControl):
|
|
|
258
258
|
|
|
259
259
|
|
|
260
260
|
class RadioButtonGroupCtrl(tkControl):
|
|
261
|
-
def __init__(self, parent: tk.Misc, app: WinBasic, owner:
|
|
261
|
+
def __init__(self, parent: tk.Misc, app: WinBasic, owner: Container, idself: str, *,
|
|
262
262
|
text: str, subctrlcfg: et.Element,
|
|
263
263
|
level: int, **options: Any):
|
|
264
264
|
ctrl = ttk.LabelFrame(parent)
|
|
@@ -267,7 +267,7 @@ class RadioButtonGroupCtrl(tkControl):
|
|
|
267
267
|
# self._var_val: tk.IntVar = tk.IntVar()
|
|
268
268
|
self._vartext: str = "_var" + text.replace(" ", "_")
|
|
269
269
|
self._app: WinBasic = app
|
|
270
|
-
self._owner:
|
|
270
|
+
self._owner: Container = owner
|
|
271
271
|
# pv(options)
|
|
272
272
|
_ = self.configure(text=text, **options)
|
|
273
273
|
# self._radbutton_lst: list[ttk.Radiobutton] = []
|
|
@@ -309,7 +309,7 @@ class RadioButtonGroupCtrl(tkControl):
|
|
|
309
309
|
|
|
310
310
|
|
|
311
311
|
class NotebookCtrl(tkControl):
|
|
312
|
-
def __init__(self, parent: tk.Misc, app: WinBasic, owner:
|
|
312
|
+
def __init__(self, parent: tk.Misc, app: WinBasic, owner: Container, idself: str, *,
|
|
313
313
|
subctrlcfg_list: list[et.Element], level: int, **options: Any):
|
|
314
314
|
ctrl = ttk.Notebook(parent, **options)
|
|
315
315
|
tkControl.__init__(self, parent, "", idself, ctrl)
|
|
@@ -650,7 +650,7 @@ class tkWM(Generic[T], Widget):
|
|
|
650
650
|
class DialogCtrl(Dialog):
|
|
651
651
|
def __init__(self, app: tkWin, dlg_cfg: et.Element):
|
|
652
652
|
attr_dict = dlg_cfg.attrib
|
|
653
|
-
super().__init__(attr_dict.get("text", ""), int(attr_dict["Width"]),
|
|
653
|
+
super().__init__(attr_dict.get("text", ""), int(attr_dict["Width"]), int(attr_dict["Height"]), app)
|
|
654
654
|
# options: dict[str, Any] = {}
|
|
655
655
|
# if "options" in attr_dict:
|
|
656
656
|
# options = eval(attr_dict["options"])
|
|
@@ -659,7 +659,6 @@ class DialogCtrl(Dialog):
|
|
|
659
659
|
self._xx: int = 0
|
|
660
660
|
self._yy: int = 0
|
|
661
661
|
self._top: tkWM[tk.Toplevel] | None = None
|
|
662
|
-
self._app: tkWin = app
|
|
663
662
|
self._alive: bool = False
|
|
664
663
|
self._idself: str = attr_dict["id"]
|
|
665
664
|
self._subctrlcfg_list: list[et.Element] = list(dlg_cfg)
|
|
@@ -706,53 +705,46 @@ class DialogCtrl(Dialog):
|
|
|
706
705
|
# self.withdraw()
|
|
707
706
|
iddlg = self._idself
|
|
708
707
|
|
|
709
|
-
frmdlg_xml = self.
|
|
708
|
+
frmdlg_xml = self.create_xml("Top", {})
|
|
710
709
|
|
|
711
710
|
id_frmain = f"frmMain{iddlg}"
|
|
712
711
|
# frmain_xml = self._app.create_xml("Frame", {"id": id_frmain}, frmdlg_xml)
|
|
713
|
-
frmain_xml = self.
|
|
712
|
+
frmain_xml = self.create_xml("ScrollableFrame", {"id": id_frmain,
|
|
714
713
|
"Width": f"{self._ww-30}", "Height": f"{self._hh-160}"}, frmdlg_xml)
|
|
715
|
-
_, frmmain_ctrl = self.
|
|
716
|
-
frmain_xml, 0
|
|
714
|
+
_, frmmain_ctrl = self.create_control(self._top,
|
|
715
|
+
frmain_xml, 0)
|
|
717
716
|
# self._idctrl_list.append(id_frmain)
|
|
718
717
|
self._idctrl_dict[id_frmain] = frmmain_ctrl
|
|
719
718
|
# frm_main = cast(tkControl, frmmain).control
|
|
720
719
|
# frm_main = cast(tkControl, frmmain_ctrl)
|
|
721
720
|
|
|
722
721
|
for sub_ctrl in self._subctrlcfg_list:
|
|
723
|
-
|
|
724
|
-
# self._idctrl_list.extend(subidctrl_list)
|
|
725
|
-
self._idctrl_dict.update(subidctrl_dict)
|
|
722
|
+
_ = self.create_controls(frmmain_ctrl, sub_ctrl, 1)
|
|
726
723
|
|
|
727
|
-
_ = self.
|
|
724
|
+
_ = self.assemble_control(frmmain_ctrl, {"layout": "pack",
|
|
728
725
|
"pack": "{'side':'top','fill':'both','expand':True,'padx':5,'pady':5}"})
|
|
729
726
|
|
|
730
|
-
frmbot_xml = self.
|
|
731
|
-
|
|
732
|
-
frmbot_xml, 0
|
|
733
|
-
# self._idctrl_list.append(id_frmbot)
|
|
734
|
-
self._idctrl_dict[id_frmbot] = frmbot_ctrl
|
|
727
|
+
frmbot_xml = self.create_xml("Frame", {"id": f"frmBot{iddlg}"}, frmdlg_xml)
|
|
728
|
+
_, frmbot_ctrl = self.create_control(self._top,
|
|
729
|
+
frmbot_xml, 0)
|
|
735
730
|
|
|
736
|
-
btnConfirm_xml = self.
|
|
731
|
+
btnConfirm_xml = self.create_xml("Button", {"id": f"btnConfirm{iddlg}",
|
|
737
732
|
"text": "Confirm", "options": "{'width':20}"}, frmbot_xml)
|
|
738
|
-
id_btnconfirm, btnConfirm_ctrl = self.
|
|
739
|
-
btnConfirm_xml, 1
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
_ = self._app.assemble_control(btnConfirm_ctrl, {"layout":"pack",
|
|
733
|
+
id_btnconfirm, btnConfirm_ctrl = self.create_control(frmbot_ctrl,
|
|
734
|
+
btnConfirm_xml, 1)
|
|
735
|
+
|
|
736
|
+
_ = self.assemble_control(btnConfirm_ctrl, {"layout":"pack",
|
|
743
737
|
"pack":"{'side':'right','fill':'both','expand':True,'padx':5,'pady':5}"}, f"{' '*1}")
|
|
744
738
|
|
|
745
|
-
bntcancel_xml = self.
|
|
739
|
+
bntcancel_xml = self.create_xml("Button", {"id": f"btnCancel{iddlg}",
|
|
746
740
|
"text": "Cancel", "options": "{'width':20}"}, frmbot_xml)
|
|
747
|
-
id_btncancel, btncancel_ctrl = self.
|
|
748
|
-
bntcancel_xml, 1
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
# pv(self._idctrl_list)
|
|
752
|
-
_ = self._app.assemble_control(btncancel_ctrl, {"layout":"pack",
|
|
741
|
+
id_btncancel, btncancel_ctrl = self.create_control(frmbot_ctrl,
|
|
742
|
+
bntcancel_xml, 1)
|
|
743
|
+
|
|
744
|
+
_ = self.assemble_control(btncancel_ctrl, {"layout":"pack",
|
|
753
745
|
"pack":"{'side':'right','fill':'both','expand':True,'padx':5,'pady':5}"}, f"{' '*1}")
|
|
754
746
|
|
|
755
|
-
_ = self.
|
|
747
|
+
_ = self.assemble_control(frmbot_ctrl, {"layout": "pack",
|
|
756
748
|
"pack": "{'side':'bottom','fill':'x','expand':True,'padx':5,'pady':5}"})
|
|
757
749
|
|
|
758
750
|
self._extral_msg = kwargs
|
|
@@ -783,9 +775,6 @@ class DialogCtrl(Dialog):
|
|
|
783
775
|
self._top.control.wait_window()
|
|
784
776
|
# pv(self._id_list)
|
|
785
777
|
|
|
786
|
-
def get_control(self, idctrl: str) -> object:
|
|
787
|
-
return self._app.get_control(idctrl)
|
|
788
|
-
|
|
789
778
|
def _do_cancel(self, **kwargs: object):
|
|
790
779
|
# po(f"Dialog {self._idself} _do_cancel")
|
|
791
780
|
self.destroy(confirm=False, **kwargs)
|
|
@@ -970,7 +959,7 @@ class tkWin(WinBasic):
|
|
|
970
959
|
|
|
971
960
|
@override
|
|
972
961
|
def create_control(self, parent: Widget, ctrl_cfg: et.Element,
|
|
973
|
-
level: int = 0, owner:
|
|
962
|
+
level: int = 0, owner: Container | None = None) -> tuple[str, Widget]:
|
|
974
963
|
if owner is None:
|
|
975
964
|
owner = self
|
|
976
965
|
tag = ctrl_cfg.tag
|
|
@@ -81,13 +81,23 @@ class Control(Widget, metaclass=abc.ABCMeta):
|
|
|
81
81
|
pass
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
class Container(Widget):
|
|
85
|
-
def __init__(self, owner: Container | None = None):
|
|
84
|
+
class Container(Widget, metaclass=abc.ABCMeta):
|
|
85
|
+
def __init__(self, title: str, width: int, height: int, owner: Container | None = None):
|
|
86
86
|
super().__init__()
|
|
87
87
|
self._eventhandler_dict: dict[str, list[EventHanlder]] = {}
|
|
88
88
|
self._msgs_hanlders: list[tuple[int, list[str], EventsHanlder]] = []
|
|
89
89
|
self._owner: Container | None = owner
|
|
90
90
|
|
|
91
|
+
self._backed: bool = True
|
|
92
|
+
|
|
93
|
+
self._xx: int = 0
|
|
94
|
+
self._yy: int = 0
|
|
95
|
+
self._ww: int = width
|
|
96
|
+
self._hh: int = height
|
|
97
|
+
self._title: str = title
|
|
98
|
+
|
|
99
|
+
self._idctrl_dict: OrderedDict[str, Widget] = OrderedDict()
|
|
100
|
+
|
|
91
101
|
@property
|
|
92
102
|
def owner(self):
|
|
93
103
|
return self._owner
|
|
@@ -96,6 +106,30 @@ class Container(Widget):
|
|
|
96
106
|
def owner(self, val: "Container"):
|
|
97
107
|
self._owner = val
|
|
98
108
|
|
|
109
|
+
@property
|
|
110
|
+
def title(self):
|
|
111
|
+
return self._title
|
|
112
|
+
|
|
113
|
+
def set_title(self, val: str):
|
|
114
|
+
self._title = val
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def pos(self):
|
|
118
|
+
return self._xx, self._yy
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
def size(self):
|
|
122
|
+
return self._ww, self._hh
|
|
123
|
+
|
|
124
|
+
def back(self, bset: bool = True):
|
|
125
|
+
for idctrl, ctrl in self._idctrl_dict.items():
|
|
126
|
+
try:
|
|
127
|
+
ctrl = cast(Control, ctrl).back(bset)
|
|
128
|
+
except AttributeError as _:
|
|
129
|
+
# po(f"{idctrl} doesn't support back")
|
|
130
|
+
print(f"{idctrl} doesn't support back")
|
|
131
|
+
self._backed = bset
|
|
132
|
+
|
|
99
133
|
def register_eventhandler(self, idmsg: str, handler: EventHanlder):
|
|
100
134
|
"""_summary_
|
|
101
135
|
|
|
@@ -155,73 +189,9 @@ class Container(Widget):
|
|
|
155
189
|
|
|
156
190
|
if self._owner is not None:
|
|
157
191
|
return self._owner.process_message(idmsg, **kwargs)
|
|
158
|
-
|
|
192
|
+
print(f"Container: undeal msg of {idmsg} with {kwargs}")
|
|
159
193
|
return None
|
|
160
194
|
|
|
161
|
-
|
|
162
|
-
class Dialog(Container, metaclass=abc.ABCMeta):
|
|
163
|
-
def __init__(self, title: str, width: int, height: int):
|
|
164
|
-
super().__init__()
|
|
165
|
-
self._xx: int = 0
|
|
166
|
-
self._yy: int = 0
|
|
167
|
-
self._title: str = title
|
|
168
|
-
self._ww: int = width
|
|
169
|
-
self._hh: int = height
|
|
170
|
-
self._backed: bool = True
|
|
171
|
-
self._idctrl_dict: OrderedDict[str, Widget] = OrderedDict()
|
|
172
|
-
|
|
173
|
-
@property
|
|
174
|
-
def title(self):
|
|
175
|
-
return self._title
|
|
176
|
-
|
|
177
|
-
def set_title(self, val: str):
|
|
178
|
-
self._title = val
|
|
179
|
-
|
|
180
|
-
@property
|
|
181
|
-
def pos(self):
|
|
182
|
-
return self._xx, self._yy
|
|
183
|
-
|
|
184
|
-
@property
|
|
185
|
-
def size(self):
|
|
186
|
-
return self._ww, self._hh
|
|
187
|
-
|
|
188
|
-
@property
|
|
189
|
-
def backed(self):
|
|
190
|
-
return self._backed
|
|
191
|
-
|
|
192
|
-
def back(self, bset: bool = True):
|
|
193
|
-
for idctrl, ctrl in self._idctrl_dict.items():
|
|
194
|
-
try:
|
|
195
|
-
ctrl = cast(Control, ctrl).back(bset)
|
|
196
|
-
except AttributeError as _:
|
|
197
|
-
# po(f"{idctrl} doesn't support back")
|
|
198
|
-
print(f"{idctrl} doesn't support back")
|
|
199
|
-
self._backed = bset
|
|
200
|
-
|
|
201
|
-
def _beforego(self, **kwargs: object):
|
|
202
|
-
_ = super().process_message("beforego", **kwargs)
|
|
203
|
-
|
|
204
|
-
def _confirm(self, **kwargs: object) -> tuple[bool, str]:
|
|
205
|
-
return cast(tuple[bool, str], super().process_message("confirm", **kwargs))
|
|
206
|
-
|
|
207
|
-
def _cancel(self, **kwargs: object) -> tuple[bool, str]:
|
|
208
|
-
return cast(tuple[bool, str], super().process_message("cancel", **kwargs))
|
|
209
|
-
|
|
210
|
-
@override
|
|
211
|
-
def process_message(self, idmsg: str, **kwargs: object):
|
|
212
|
-
match idmsg:
|
|
213
|
-
case "beforego":
|
|
214
|
-
self._beforego(**kwargs)
|
|
215
|
-
case "confirm":
|
|
216
|
-
return self._confirm(**kwargs)
|
|
217
|
-
case "cancel":
|
|
218
|
-
return self._cancel(**kwargs)
|
|
219
|
-
case _:
|
|
220
|
-
# if self._owner is not None:
|
|
221
|
-
# return self._owner.process_message(idmsg, **kwargs)
|
|
222
|
-
return super().process_message(idmsg, **kwargs)
|
|
223
|
-
return True
|
|
224
|
-
|
|
225
195
|
@abc.abstractmethod
|
|
226
196
|
def destroy(self, **kwargs: object):
|
|
227
197
|
# self._eventhandler_dict.clear()
|
|
@@ -231,7 +201,7 @@ class Dialog(Container, metaclass=abc.ABCMeta):
|
|
|
231
201
|
pass
|
|
232
202
|
|
|
233
203
|
|
|
234
|
-
class WinBasic(
|
|
204
|
+
class WinBasic(Container, metaclass=abc.ABCMeta):
|
|
235
205
|
def __init__(self, xmlfile: str):
|
|
236
206
|
element_tree = et.parse(xmlfile)
|
|
237
207
|
self._wincfg: et.Element[str] = element_tree.getroot()
|
|
@@ -240,7 +210,7 @@ class WinBasic(Dialog, metaclass=abc.ABCMeta):
|
|
|
240
210
|
w, h = int(win_attr["Width"]), int(win_attr["Height"])
|
|
241
211
|
else:
|
|
242
212
|
w, h = 0, 0
|
|
243
|
-
|
|
213
|
+
super().__init__(win_attr["Title"], w, h)
|
|
244
214
|
|
|
245
215
|
self._customctrl_dict: dict[str, et.Element] = {}
|
|
246
216
|
|
|
@@ -258,7 +228,7 @@ class WinBasic(Dialog, metaclass=abc.ABCMeta):
|
|
|
258
228
|
|
|
259
229
|
@abc.abstractmethod
|
|
260
230
|
def create_control(self, parent: Widget, ctrl_cfg: et.Element,
|
|
261
|
-
level: int = 0, owner:
|
|
231
|
+
level: int = 0, owner: Container | None = None) -> tuple[str, Widget]:
|
|
262
232
|
pass
|
|
263
233
|
|
|
264
234
|
@abc.abstractmethod
|
|
@@ -266,7 +236,7 @@ class WinBasic(Dialog, metaclass=abc.ABCMeta):
|
|
|
266
236
|
pass
|
|
267
237
|
|
|
268
238
|
def create_controls(self, parent: Widget, ctrl_cfg: et.Element,
|
|
269
|
-
level: int = 0, owner:
|
|
239
|
+
level: int = 0, owner: Container | None = None) -> OrderedDict[str, Widget]:
|
|
270
240
|
idctrl_dict: OrderedDict[str, Widget] = OrderedDict()
|
|
271
241
|
tag = ctrl_cfg.tag
|
|
272
242
|
if tag == "CustomDialog":
|
|
@@ -293,7 +263,7 @@ class WinBasic(Dialog, metaclass=abc.ABCMeta):
|
|
|
293
263
|
ctrl.destroy()
|
|
294
264
|
except AttributeError:
|
|
295
265
|
# po(f"Warnning: {idctrl} doesn't have destroy")
|
|
296
|
-
print(f"
|
|
266
|
+
print(f"WinBasic warnning: {idctrl} doesn't have destroy")
|
|
297
267
|
del self._idctrl_dict[idctrl]
|
|
298
268
|
|
|
299
269
|
def get_control(self, idctrl: str):
|
|
@@ -325,3 +295,62 @@ class WinBasic(Dialog, metaclass=abc.ABCMeta):
|
|
|
325
295
|
self._idctrl_dict.clear()
|
|
326
296
|
|
|
327
297
|
super().destroy(**kwargs)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
class Dialog(Container, metaclass=abc.ABCMeta):
|
|
301
|
+
def __init__(self, title: str, width: int, height: int, app: WinBasic):
|
|
302
|
+
super().__init__(title, width, height)
|
|
303
|
+
self._app: WinBasic = app
|
|
304
|
+
|
|
305
|
+
@property
|
|
306
|
+
def backed(self):
|
|
307
|
+
return self._backed
|
|
308
|
+
|
|
309
|
+
def _beforego(self, **kwargs: object):
|
|
310
|
+
_ = super().process_message("beforego", **kwargs)
|
|
311
|
+
|
|
312
|
+
def create_xml(self, tag: str, attr_dict: dict[str, str], root: et.Element | None = None) -> et.Element:
|
|
313
|
+
return self._app.create_xml(tag, attr_dict, root)
|
|
314
|
+
|
|
315
|
+
def create_controls(self, parent: Widget, ctrl_cfg: et.Element,
|
|
316
|
+
level: int = 0) -> OrderedDict[str, Widget]:
|
|
317
|
+
subidctrl_dict = self._app.create_controls(parent,ctrl_cfg, level, self)
|
|
318
|
+
self._idctrl_dict.update(subidctrl_dict)
|
|
319
|
+
return subidctrl_dict
|
|
320
|
+
|
|
321
|
+
def create_control(self, parent: Widget, ctrl_cfg: et.Element,
|
|
322
|
+
level: int = 0) -> tuple[str, Widget]:
|
|
323
|
+
id_ctrl, ctrl = self._app.create_control(parent, ctrl_cfg, level, self)
|
|
324
|
+
self._idctrl_dict[id_ctrl] = ctrl
|
|
325
|
+
return id_ctrl, ctrl
|
|
326
|
+
|
|
327
|
+
def assemble_control(self, ctrl: Widget, attr_dict: dict[str, str], prefix: str = ""):
|
|
328
|
+
return self._app.assemble_control(ctrl, attr_dict, prefix)
|
|
329
|
+
|
|
330
|
+
def get_control(self, idctrl: str) -> object:
|
|
331
|
+
return self._app.get_control(idctrl)
|
|
332
|
+
|
|
333
|
+
def delete_control(self, idctrl: str):
|
|
334
|
+
self._app.delete_control(idctrl)
|
|
335
|
+
del self._idctrl_dict[idctrl]
|
|
336
|
+
|
|
337
|
+
def _confirm(self, **kwargs: object) -> tuple[bool, str]:
|
|
338
|
+
return cast(tuple[bool, str], super().process_message("confirm", **kwargs))
|
|
339
|
+
|
|
340
|
+
def _cancel(self, **kwargs: object) -> tuple[bool, str]:
|
|
341
|
+
return cast(tuple[bool, str], super().process_message("cancel", **kwargs))
|
|
342
|
+
|
|
343
|
+
@override
|
|
344
|
+
def process_message(self, idmsg: str, **kwargs: object):
|
|
345
|
+
match idmsg:
|
|
346
|
+
case "beforego":
|
|
347
|
+
self._beforego(**kwargs)
|
|
348
|
+
case "confirm":
|
|
349
|
+
return self._confirm(**kwargs)
|
|
350
|
+
case "cancel":
|
|
351
|
+
return self._cancel(**kwargs)
|
|
352
|
+
case _:
|
|
353
|
+
# if self._owner is not None:
|
|
354
|
+
# return self._owner.process_message(idmsg, **kwargs)
|
|
355
|
+
return super().process_message(idmsg, **kwargs)
|
|
356
|
+
return True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|