Ejemplo n.º 1
0
    def stop(self):
        self.cw.stop()
        sys.exit()


if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    clipboard = app.clipboard()

    # add icon
    app_icon = QIcon()
    app_icon.addFile(path.join("qml", "img", "logo.jpg"))
    app.setWindowIcon(app_icon)

    engine = QQmlApplicationEngine()
    ctx = engine.rootContext()
    py = QMLNameSpace(engine, clipboard)
    ctx.setContextProperty("main", engine)
    ctx.setContextProperty("py", py)

    # engine.addImportPath(path.join(getcwd(), 'qml'))
    engine.setImportPathList([path.join(getcwd(), "qml", "lib")])

    engine.load("qml/gui.qml")

    window = engine.rootObjects()[0]
    window.show()

    app.aboutToQuit.connect(py.stop)
    sys.exit(app.exec_())