diff --git a/.gitignore b/.gitignore index 3f3c6fb..c2cb1ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -Scorganizr.pyproject.user +Scorganizr.pyproject.user* __pycache__/ diff --git a/Scorganizr.pyproject b/Scorganizr.pyproject index 51ec4a5..d38a669 100644 --- a/Scorganizr.pyproject +++ b/Scorganizr.pyproject @@ -1,3 +1,3 @@ { - "files": ["main.py", "form.ui"] + "files": ["main.ui","main.py","utils.py"] } diff --git a/main.py b/main.py index 08ce629..03f1583 100644 --- a/main.py +++ b/main.py @@ -1,19 +1,25 @@ # This Python file uses the following encoding: utf-8 + import sys - -from PySide6.QtWidgets import QApplication, QMainWindow -from ui_form import Ui_MainWindow - - -class MainWindow(QMainWindow): - def __init__(self, parent=None): - super().__init__(parent) - self.ui = Ui_MainWindow() - self.ui.setupUi(self) +from PySide6.QtWidgets import QApplication +from PySide6.QtCore import QFile, QIODevice +from PySide6.QtUiTools import QUiLoader if __name__ == "__main__": app = QApplication(sys.argv) - widget = MainWindow() - widget.show() + + ui_file_name = "main.ui" + ui_file = QFile(ui_file_name) + if not ui_file.open(QIODevice.ReadOnly): + print(f"Cannot open {ui_file_name}: {ui_file.errorString()}") + sys.exit(-1) + loader = QUiLoader() + window = loader.load(ui_file) + ui_file.close() + if not window: + print(loader.errorString()) + sys.exit(-1) + window.show() + sys.exit(app.exec()) diff --git a/form.ui b/main.ui similarity index 100% rename from form.ui rename to main.ui