Added comments in main.py; the Logger utility is used now

This commit is contained in:
Blue Fox 2023-07-09 10:09:26 +02:00
parent bf5ac71380
commit 995b00d65d

12
main.py
View File

@ -20,22 +20,26 @@ import sys
from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QApplication
from PySide6.QtCore import QFile, QIODevice from PySide6.QtCore import QFile, QIODevice
from PySide6.QtUiTools import QUiLoader from PySide6.QtUiTools import QUiLoader
from utils import Logger
if __name__ == "__main__": if __name__ == "__main__":
# needed variables
app = QApplication(sys.argv) app = QApplication(sys.argv)
logger = Logger()
ui_file_name = "main.ui" ui_file_name = "main.ui"
# create the window
ui_file = QFile(ui_file_name) ui_file = QFile(ui_file_name)
if not ui_file.open(QIODevice.ReadOnly): if not ui_file.open(QIODevice.ReadOnly):
print(f"Cannot open {ui_file_name}: {ui_file.errorString()}") logger.log(f"Cannot open {ui_file_name}: {ui_file.errorString()}", 1)
sys.exit(-1) sys.exit(-1)
loader = QUiLoader() window = QUiLoader().load(ui_file)
window = loader.load(ui_file)
ui_file.close() ui_file.close()
if not window: if not window:
print(loader.errorString()) print(loader.errorString())
sys.exit(-1) sys.exit(-1)
window.show() window.show()
# run as long as the app is executing
sys.exit(app.exec()) sys.exit(app.exec())