73 lines
1.6 KiB
Python
73 lines
1.6 KiB
Python
# This Python file uses the following encoding: utf-8
|
|
import sys
|
|
from pathlib import Path
|
|
from PySide6.QtGui import QGuiApplication
|
|
from PySide6.QtQml import QQmlApplicationEngine
|
|
from PySide6.QtCore import QResource
|
|
from lib.ConfigLoader import ConfigLoader
|
|
from lib.DataBase import DataBase
|
|
import rc_pyqcrm
|
|
import sqlite3
|
|
|
|
# [pyqcrm]
|
|
# program-name=""
|
|
# version=
|
|
|
|
# [database]
|
|
# server=""
|
|
# port=
|
|
# user=""
|
|
# password=""
|
|
# name=""
|
|
# type=""
|
|
def testConnection():
|
|
connection= sqlite3.connect(":memory:")
|
|
cur= connection.cursor()
|
|
cur.execute("CREATE TABLE test(id INTEGER primary key, Kundenname TEXT, Ort TEXT)")
|
|
cur.execute("""
|
|
INSERT INTO test VALUES
|
|
(1, 'Gruva', 'Dusseldorf'),
|
|
(2, 'Tero', 'Krefeld'),
|
|
(3, 'Blabla','Paris')
|
|
""")
|
|
connection.commit()
|
|
return connection
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
#QResource.registerResource("rc_qml.py")
|
|
app = QGuiApplication(sys.argv)
|
|
engine = QQmlApplicationEngine()
|
|
|
|
engine.addImportPath("qrc:/");
|
|
|
|
|
|
|
|
bad_config = False
|
|
|
|
|
|
|
|
qml_file = Path(__file__).resolve().parent / "gui/main.qml"
|
|
|
|
#qml_file = ":/gui/main.qml"
|
|
|
|
config = ConfigLoader()
|
|
|
|
con = testConnection()
|
|
dbm = DataBase(con)
|
|
|
|
if not config.getConfig():
|
|
bad_config = True
|
|
|
|
|
|
engine.rootContext().setContextProperty("dbm", dbm)
|
|
engine.rootContext().setContextProperty("bad_config", bad_config) # print(f"Fehler: {i}")
|
|
engine.rootContext().setContextProperty("config", config)
|
|
engine.load(qml_file)
|
|
|
|
|
|
if not engine.rootObjects():
|
|
sys.exit(-1)
|
|
sys.exit(app.exec())
|