Scorganizr/main.py

46 lines
1.4 KiB
Python

"""
Main application
Copyright (C) 2023 Benjamin Burkhardt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import sys
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import QFile, QIODevice
from PySide6.QtUiTools import QUiLoader
from utils import Logger
if __name__ == "__main__":
# needed variables
app = QApplication(sys.argv)
logger = Logger()
ui_file_name = "main.ui"
# create the window
ui_file = QFile(ui_file_name)
if not ui_file.open(QIODevice.ReadOnly):
logger.log(f"Cannot open {ui_file_name}: {ui_file.errorString()}. Exiting.", 1)
sys.exit(-1)
window = QUiLoader().load(ui_file)
ui_file.close()
if not window:
logger.log(loader.errorString(), 1)
sys.exit(-1)
window.show()
# run as long as the app is executing
sys.exit(app.exec())