forked from FooSoft/mangle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (35 loc) · 1.51 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import sys
from PyQt6.QtCore import QObject, pyqtSlot, QUrl, pyqtSignal, QStringListModel, QAbstractListModel, QModelIndex, Qt, QVariant
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QApplication, QFileDialog
from PyQt6.QtQml import QQmlApplicationEngine
from henskan.ui_controller import UIController
from henskan.file_path_model import FilePathModel
import henskan
if __name__ == "__main__":
lib_dir = os.path.dirname(henskan.__file__)
app = QApplication(sys.argv)
app.setWindowIcon(QIcon(os.path.join(lib_dir, 'img', 'splash.jpg')))
# Create the QML application engine
engine = QQmlApplicationEngine()
print(f"engine: {engine}")
# File list elements display
file_path_model = FilePathModel()
# Create the backend object
ui_controller = UIController(engine, file_path_model)
print(f"UI Controller: {ui_controller}")
# Expose the backend object to QML
engine.rootContext().setContextProperty("ui_controller", ui_controller)
engine.rootContext().setContextProperty("file_path_model", file_path_model)
print(f"Backend is set")
# Load the QML file
ui_file = os.path.join(lib_dir, 'ui', 'main.qml')
engine.load(QUrl.fromLocalFile(ui_file))
print(f"engine loaded")
# Get the controller know about parameters controllers, and disabled them all
ui_controller.load_components()
if not engine.rootObjects():
print("Error: No root objects")
sys.exit(-1)
sys.exit(app.exec())