2
0
forked from awendt/pyrelacs
minipyrelacs/pyrelacs/app.py

48 lines
1.4 KiB
Python

import sys
from PyQt6.QtCore import QSettings
from PyQt6.QtWidgets import QApplication
from pyrelacs import info
from pyrelacs.ui.mainwindow import PyRelacs
from pyrelacs.util.logging import config_logging
import resources
log = config_logging()
from . import resources # best created with pyside6-rcc resources.qrc -o resources.py (rcc produces an error...)
def main():
app = QApplication(sys.argv)
app.setApplicationName(info.NAME)
app.setApplicationVersion(str(info.VERSION))
app.setOrganizationDomain(info.ORGANIZATION)
# app.setAttribute(Qt.ApplicationAttribute.AA_DontShowIconsInMenus, False)
# read window settings
settings = QSettings(info.ORGANIZATION, info.NAME)
width = int(settings.value("app/width", 1024))
height = int(settings.value("app/height", 768))
x = int(settings.value("app/pos_x", 100))
y = int(settings.value("app/pos_y", 100))
window = PyRelacs()
window.setMinimumWidth(200)
window.setMinimumHeight(200)
window.resize(width, height)
window.move(x, y)
window.show()
exit_code = app.exec()
# store window position and size
pos = window.pos()
settings.setValue("app/width", window.width())
settings.setValue("app/height", window.height())
settings.setValue("app/pos_x", pos.x())
settings.setValue("app/pos_y", pos.y())
sys.exit(exit_code)
if __name__ == "__main__":
main()