# This Python file uses the following encoding: utf-8 import sys import os import signal import PyQt5 from PySide2.QtGui import QGuiApplication from PySide2.QtQml import QQmlApplicationEngine from PySide2.QtCore import SIGNAL, QObject, Slot dirname = os.path.dirname(PyQt5.__file__) plugin_path = os.path.join(dirname, "plugins", "platforms") os.environ["QML2_IMPORT_PATH"] = os.path.join(dirname, "qml") application_path = ( os.path.join(os.path.dirname(sys.executable), "assets") if getattr(sys, "frozen", False) else os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets") ) if __name__ == "__main__": signal.signal( signal.SIGINT, signal.SIG_DFL ) # https://stackoverflow.com/questions/4938723/what-is-the-correct-way-to-make-my-pyqt-application-quit-when-killed-from-the-co app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() print("HELLO") engine.load(os.path.join(application_path, "main.qml")) if not engine.rootObjects(): sys.exit(-1) root = engine.rootObjects()[0] def cb(): print(root.getSelectedLocation()) QGuiApplication.quitOnLastWindowClosed() root.close() root.selected.connect(cb) sys.exit(app.exec_())