st-ten-1/src/ui/window/window.py

39 lines
1.0 KiB
Python
Raw Normal View History

2022-06-01 16:37:19 +00:00
import logging
from lib.helpers import get_resource
from PyQt5 import uic
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QMainWindow
from ui.dialog import Dialog
class Window(QMainWindow):
_closing = pyqtSignal()
def __init__(self):
super().__init__()
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowFlags(Qt.Window)
me = self.__class__.__name__
u = get_resource("ui/{0}/{0}.ui".format(me.lower()))
self.ui = uic.loadUi(u, self)
# LOGO
self.setWindowIcon(QIcon(get_resource("ui/imgs/neo.ico")))
self.log = logging.getLogger(f"{self.__class__.__name__} ({id(self)})")
def setCentralWidget(self, widget):
widget.setParent(self)
super().setCentralWidget(widget)
def open_dialog(self, widget, show=True):
d = Dialog()
widget.setParent(self)
d.setCentralWidget(widget)
if show:
d.show()
return d
def closeEvent(self, *args):
self._closing.emit()