# -*- coding: utf-8 -*- #from PyQt5.QtGui import QApplication from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import QVariant, QUrl, QDir from PyQt5.QtQml import QQmlApplicationEngine, QQmlEngine from PyQt5.QtQuick import QQuickView, QQuickItem, QQuickWindow if __name__ == '__main__': import sys app = QApplication(sys.argv) viewer = QQuickView() viewer.setSource(QUrl("main.qml")) viewer.setTitle("Material Demo QML") viewer.engine().quit.connect(app.quit) viewer.resize(500, 500) viewer.setResizeMode(QQuickView.SizeRootObjectToView) viewer.show() sys.exit(app.exec_())
#!/usr/bin/env python import sys import os from simple_ellipse import SimpleEllipse from PyQt5.QtQml import qmlRegisterType from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView from PyQt5.QtCore import QUrl if __name__ == '__main__': app = QApplication(sys.argv) qmlRegisterType(SimpleEllipse, "Shapes", 1, 0, "SimpleEllipse") view = QQuickView() view.resize(480, 480) view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(QUrl.fromLocalFile( os.path.join(os.path.dirname(__file__), 'qml/main.qml'))) view.show() sys.exit(app.exec_())
from PyQt5.QtQml import QQmlContext, qmlRegisterType from PyQt5.QtQuick import QQuickView from PyQt5.QtCore import QUrl from context import Context from PyQt5.QtQml import QQmlListProperty from plateau import Plateau from case import Case from qplateau import QPlateau from qcase import QCase if __name__ == "__main__": app = QGuiApplication(sys.argv) myApp = Context() view = QQuickView() view.resize(800, 800) view.setResizeMode(QQuickView.SizeRootObjectToView) qmlRegisterType(QPlateau, 'temp', 1, 0, 'QPlateau') qmlRegisterType(QCase, 'temp0', 1, 0, 'QCase') ctx = view.rootContext() myApp.setContext( ctx ) view.setSource(QUrl("qml/main.qml")) view.show() sys.exit(app.exec_())
#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys import os from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView from PyQt5.QtCore import QUrl if __name__ == '__main__': app = QApplication(sys.argv) view = QQuickView() view.resize(800, 600) view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource( QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__), 'main.qml'))) view.show() sys.exit(app.exec_())