st-ten-1/src/ui/main_window/main_window.py
2024-10-24 13:34:14 +02:00

37 lines
1.0 KiB
Python

from PyQt6 import sip
from PyQt6.QtCore import pyqtSignal
from ui.window import Window
class Main_Window(Window):
do = pyqtSignal(dict)
def __init__(self):
super().__init__()
self.do.connect(self._do)
# print("MAIN_WINDOW ", str(int(QThread.currentThreadId())), flush=True)
@staticmethod
def _do(config):
return config["f"](*config.get("a", []), **config.get("k", {}))
def open_tab(self, widget):
self.setCentralWidget(widget)
def open_window(self, widget, show=True, maximized=False):
wt = widget.__class__.__name__
if wt not in self.windows or self.windows[wt] is None or sip.isdeleted(self.windows[wt]):
w = Window()
self.windows[wt] = w
w.setCentralWidget(widget)
if show:
if maximized:
w.showMaximized()
else:
w.show()
return w
else:
self.windows[wt].activateWindow()
return self.windows[wt]