Beispiel #1
0
def main():
    app = QApplication([])
    """ 指定したクラスを、QMLモジュールのQMLタイプとしてバインディングする
            qmlRegisterType(class, uri, versionMajor, versionMinor, qmlName)
            class        - QML側でQML Type定義するPythonクラス
            uri          - 定義するQMLモジュール名
            versionMajor - QMLモジュールのメジャーバージョン 
            versionMinor - QMLモジュールのマイナーバージョン
            qmlName      - 定義するQMLタイプ名
    """
    qmlRegisterType(PythonText, "FromPythonTextLibrary", 1, 0,
                    "FromPythonText")

    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)

    url = QUrl("HelloWorld.qml")
    view.setSource(url)
    if view.status() == QQuickView.Error:
        sys.exit(-1)
    view.show()

    ret = app.exec_()
    del view
    sys.exit(ret)
    def testIncubateWhileCall(self):
        app = QGuiApplication(sys.argv)
        view = QQuickView()
        controller = CustomIncubationController(self)
        view.engine().setIncubationController(controller)
        view.setResizeMode(QQuickView.SizeRootObjectToView)
        view.setSource(
            QUrl.fromLocalFile(
                adjust_filename('qqmlincubator_incubateWhile.qml', __file__)))
        view.show()

        root = view.rootObject()
        # The QML code will issue an interrupt signal after half of its items are loaded.
        root.shouldInterrupt.connect(controller.interrupter)
        res = app.exec_()

        itemsToCreate = root.property("itemsToCreate")
        loadedItems = root.property("loadedItems")
        self.assertEqual(loadedItems, itemsToCreate / 2)

        # Finish incubating the remaining items.
        controller.incubateFor(1000)
        loadedItems = root.property("loadedItems")
        self.assertEqual(loadedItems, itemsToCreate)

        # Deleting the view before it goes out of scope is required to make sure all child QML
        # instances are destroyed in the correct order.
        del view
        del app
def main():
    qInstallMessageHandler(lambda x, y, msg: print(msg))

    argv = sys.argv

    # Trick to set the style / not found how to do it in pythonic way
    #argv.extend(["-style", "universal"])
    app = QGuiApplication(argv)

    qmlRegisterType(FigureCanvasQTAgg, "Backend", 1, 0, "FigureCanvasByPython")

    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(QUrl(str(pathlib.Path(__file__).parent / 'Figure.qml')))
    view.show()

    win = view.rootObject()
    qml_figure_canvas = win.findChild(QObject, "figure")
    fig = qml_figure_canvas.getFigure()
    print(fig)
    ax = fig.add_subplot(111)
    x = np.linspace(-5, 5)
    ax.plot(x, np.sin(x))

    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc)
Beispiel #4
0
def main():
    argv = sys.argv

    app = QGuiApplication(argv)

    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0,
                    "FigureToolbarByPython")

    # this should work in the future
    # qmlRegisterType(
    #     QUrl.fromLocalFile( str(pathlib.Path(backend_qquick5agg.__file__)/'SubplotTool.qml')),
    #     "Backend", 1, 0, "SubplotTool")

    imgProvider = MatplotlibIconProvider()
    view = QQuickView()

    view.engine().addImageProvider("mplIcons", imgProvider)
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(
        QUrl(str(pathlib.Path(__file__).parent / 'FigureToolbar.qml')))

    win = view.rootObject()
    fig = win.findChild(QObject, "figure").getFigure()
    ax = fig.add_subplot(111)
    x = np.linspace(-5, 5)
    ax.plot(x, np.sin(x))

    view.show()

    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc)
Beispiel #5
0
def main(argv):
    data = [
        [4, 9, 2],
        [1, 0, 0],
        [3, 5, 0],
        [3, 3, 2],
        [7, 8, 9],
    ]

    myModel = BasicModel(data)


    app = QtWidgets.QApplication(argv)
    view = QQuickView()
    view.rootContext().setContextProperty("myModel", myModel)
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.resize(640, 480)

    url = QtCore.QUrl("table.qml")

    result = view.setSource(url)

    # TODO somehow connect myModel python to QML Table view.

    view.show()
    sys.exit(app.exec_())
Beispiel #6
0
def brunchmark():
    app = QApplication([])
    view = QQuickView()
    url = QUrl("./brunchmark/brunchmark.qml")

    view.setSource(url)
    view.show()
    app.exec_()

    # app = QApplication([])
    # engine = QQmlApplicationEngine()
    # engine.load("./brunchmark/brunchmark.qml")
    # win = engine.rootObjects()[0]
    # win.show()
    # sys.exit(app.exec_())


# if __name__ == "__main__":
#     app = QApplication(sys.argv)

#     widget = MyWidget()
#     widget.resize(800, 600)
#     widget.show()

#     sys.exit(app.exec_())
Beispiel #7
0
 def testAbstractItemModelTransferToQML(self):
     view = QQuickView()
     view.setSource(QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__)))
     root = view.rootObject()
     model = ListModel()
     root.setProperty('model', model)
     view.show()
Beispiel #8
0
 def testAbstractItemModelTransferToQML(self):
     view = QQuickView()
     model = ListModel()
     view.rootContext().setContextProperty("pythonModel", model)
     view.setSource(QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__)))
     root = view.rootObject()
     view.show()
Beispiel #9
0
def main():
    app = QApplication([])
    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)

    # QML経由でアクセスするPythonTextクラスのインスタンスを生成する
    python_text = PythonText()
    # QMLのrootアイテムのコンテキストを取得する
    context = view.rootContext()
    """ QMLの rootアイテムにQML側からアクセスするPythonのクラスを登録する
            PySide2.QtQml.QQmlContext.setContextProperty(arg__1, arg__2)
            arg__1 – QML側からアクセスするためのQMLオブジェクト名
            arg__2 - QML側からアクセスさせるPythonクラス
    """
    context.setContextProperty("pythonText", python_text)

    url = QUrl("HelloWorld.qml")
    view.setSource(url)
    if view.status() == QQuickView.Error:
        sys.exit(-1)

    view.show()
    ret = app.exec_()
    del view
    sys.exit(ret)
Beispiel #10
0
def main(argv):
    app = QtWidgets.QApplication(argv)
    view = QQuickView()
    url = QtCore.QUrl("basic.qml")

    view.setSource(url)
    view.show()
    sys.exit(app.exec_())
Beispiel #11
0
def hello_QML():
    app = QApplication([])
    view = QQuickView()
    url = QUrl("view.qml")

    view.setSource(url)
    view.show()
    app.exec_()
Beispiel #12
0
def main():
    '''main entry point'''
    app = QApplication([])

    view = QQuickView()
    view.setSource(QUrl("view.qml"))
    view.show()
    app.exec_()
Beispiel #13
0
def run():
    app = QApplication(sys.argv)
    view = QQuickView()
    url = QUrl(os.path.join(os.path.dirname(__file__), 'view.qml'))

    view.setSource(url)
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.show()
    app.exec_()
Beispiel #14
0
 def testIt(self):
     app = QGuiApplication([])
     qmlRegisterType(MyClass,'Example',1,0,'MyClass')
     view = QQuickView()
     view.setSource(QUrl.fromLocalFile(adjust_filename('bug_926.qml', __file__)))
     self.assertEqual(len(view.errors()), 0)
     view.show()
     QTimer.singleShot(0, app.quit)
     app.exec_()
Beispiel #15
0
 def testIt(self):
     app = QGuiApplication([])
     qmlRegisterType(MyClass, 'Example', 1, 0, 'MyClass')
     view = QQuickView()
     view.setSource(
         QUrl.fromLocalFile(adjust_filename('bug_926.qml', __file__)))
     self.assertEqual(len(view.errors()), 0)
     view.show()
     QTimer.singleShot(0, app.quit)
     app.exec_()
    def testQQuickNetworkFactory(self):
        view = QQuickView()

        url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__))

        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QQuickView.Ready)

        self.app.exec_()
Beispiel #17
0
    def testModelExport(self):
        view = QQuickView()
        dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")]

        ctxt = view.rootContext()
        ctxt.setContextProperty("myModel", dataList)

        url = QUrl.fromLocalFile(adjust_filename('viewmodel.qml', __file__))
        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QQuickView.Ready)
Beispiel #18
0
    def testIt(self):
        global paintCalled
        app = QGuiApplication([])
        qmlRegisterType(Bug825, 'bugs', 1, 0, 'Bug825')
        self.assertRaises(TypeError, qmlRegisterType, A, 'bugs', 1, 0, 'A')

        view = QQuickView()
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_825.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(paintCalled)
Beispiel #19
0
    def testIt(self):
        app = QGuiApplication([])

        qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart');
        qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice");

        view = QQuickView()
        view.setSource(QUrl.fromLocalFile(helper.adjust_filename('registertype.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(appendCalled)
        self.assertTrue(paintCalled)
Beispiel #20
0
    def testQQuickNetworkFactory(self):
        view = QQuickView()
        self.factory = CustomFactory()
        view.engine().setNetworkAccessManagerFactory(self.factory)

        url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__))

        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QQuickView.Ready)

        self.app.exec_()
Beispiel #21
0
def main(argv):
    app = QApplication(argv)
    view = QQuickView(
        QUrl.fromLocalFile(str(entry_path.joinpath("./view.qml").resolve())))

    # engine = QQmlApplicationEngine()
    # engine.load()
    # login.setModality(Qt.WindowModality.ApplicationModal)
    # window.setMinimumSize(QSize(400, 250))
    print(view.children())
    print(view.rootObject().findChild(QQmlComponent, "test"))
    view.show()

    return app.exec_()
Beispiel #22
0
    def testSignalArguments(self):
        view = QQuickView()
        obj = Obj()

        context = view.rootContext()
        context.setContextProperty("o", obj)
        view.setSource(QUrl.fromLocalFile(adjust_filename('signal_arguments.qml', __file__)))
        root = view.rootObject()
        self.assertTrue(root)
        button = root.findChild(QObject, "button")
        self.assertTrue(button)
        view.show()
        button.clicked.emit()
        self.assertEqual(obj.value, 42)
Beispiel #23
0
    def testIt(self):
        app = QGuiApplication([])

        qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart')
        qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice")

        view = QQuickView()
        view.setSource(
            QUrl.fromLocalFile(adjust_filename('registertype.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(appendCalled)
        self.assertTrue(paintCalled)
Beispiel #24
0
def main():
    app = QApplication([])
    view = QQuickView()

    view.setResizeMode(QQuickView.SizeRootObjectToView)

    url = QUrl("HelloWorld.qml")
    view.setSource(url)
    if view.status() == QQuickView.Error:
        sys.exit(-1)

    view.show()

    ret = app.exec_()

    del view
    sys.exit(ret)
    def testQQuickViewList(self):
        view = QQuickView()

        dataList = ["Item 1", "Item 2", "Item 3", "Item 4"]

        ctxt = view.rootContext()
        ctxt.setContextProperty("myModel", dataList)

        url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__))
        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QQuickView.Ready)
        rootObject = view.rootObject()
        self.assertTrue(rootObject)
        self.assertTrue(QtQml.qmlEngine(rootObject))
        self.assertTrue(QtQml.qmlContext(rootObject))
Beispiel #26
0
class ppGCSMain(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("pppGCS : Plural Python Parrot GCS")

        self.DeviceInfo = ppDeviceInfoWidget()
        self.DeviceList = ppDiscoverWidget()
        self.leftcol_layout = QVBoxLayout()
        self.leftcol_layout.addWidget(self.DeviceInfo)
        self.leftcol_layout.addWidget(self.DeviceList)

        self.VideoViewer = ppVideoWidget()

        self.tabs = QTabWidget()
        self.tabs.addTab(self.VideoViewer, "Video stream")
        self.mapview = QQuickView()
        self.mapcontainer = QWidget.createWindowContainer(self.mapview, self)
        url = QUrl("map.qml")
        self.mapview.setSource(url)
        self.mapview.show()
        self.tabs.addTab(self.mapcontainer, "map view")

        self.FlightInfo = ppFlightInfoWidget()
        self.ControlInfo = ppControlWidget()
        self.rightcol_layout = QVBoxLayout()
        self.rightcol_layout.addWidget(self.tabs)
        self.lowrightcol_layout = QHBoxLayout()
        self.lowrightcol_layout.addWidget(self.FlightInfo)
        self.lowrightcol_layout.addWidget(self.ControlInfo)
        self.rightcol_layout.addLayout(self.lowrightcol_layout)

        self.layout = QHBoxLayout()
        self.layout.addLayout(self.leftcol_layout)
        self.layout.addLayout(self.rightcol_layout)

        self.setLayout(self.layout)

        self.DeviceList.DeviceChanged.connect(self.on_device_changed)

    def on_device_changed(self, device):
        self.VideoViewer.close_video()
        self.VideoViewer.open_video(device.sdpfile)
        self.DeviceInfo.device = device
        self.FlightInfo.device = device
        self.ControlInfo.device = device
Beispiel #27
0
def main():
    """
    Entry point into program
    """
    app = QGuiApplication(sys.argv)

    # Register the Backend which can be used in the qml view
    qmlRegisterType(Backend, 'Interface', 1, 0, 'Backend')

    # Create a quickview widget and load the view
    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(QUrl.fromLocalFile('view.qml'))
    view.show()
    res = app.exec_()

    # Deleting the view before it goes out of scope is required to make
    # sure all child QML instances are destroyed in the correct order.
    # Sept 2019 * Not sure if we still need to do this *
    del view
    sys.exit(res)
Beispiel #28
0
def main():
    """ .qml ファイルのロードする準備
    QGuiApplication と QQuickView のインスタンスを生成する
    """
    app = QApplication([])
    view = QQuickView()
    """ Qt Quickの表示方法の設定
    PySide2.QtQuick.QQuickView.ResizeMode の enum 定義
    
    表示サイズはQMLのrootのQML rootアイテム(topの QMLオブジェクト)で
    サイズ変更されます。
    QQuickView.SizeViewToRootObject	: 表示はQMLの rootアイテム
                                      (topのQMLオブジェクト)でサイズ変更する
    QQuickView.SizeRootObjectToView	 : 表示は、rootアイテムサイズに
                                       QMLのオブジェクトが自動的に調整する
    """
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    """ 画面表示するQMLコンポーネントの読み出し
    URL形式で画面表示するQMLファイルを設定する。
    """
    url = QUrl("HelloWorld.qml")
    view.setSource(url)
    if view.status() == QQuickView.Error:
        sys.exit(-1)

    # QMLコンポーネントの表示
    view.show()

    # QApplicationのイベントループ
    ret = app.exec_()
    """ アプリケーションの終了処理
    注意:
      アプリケーション終了前にQQuickViewのオブジェクトを
       delしてから終了させる。
    """
    del view
    sys.exit(ret)
def viewload():
    app = QGuiApplication(sys.argv)
    view = QQuickView()
    view_model = URControlViewModel()
    ur_singal = view_model.gui
    view.rootContext().setContextProperty("urSingal", ur_singal)
    # qmlRegisterType(UIsignal, 'PySignal', 1, 0, 'PySignal') # implicit error when using slot and singal
    qmlRegisterType(ur_visual.FboItem, "QmlVTK", 1, 0, "VtkFboItem")

    view.setSource(QUrl.fromLocalFile(abs_path("qmlRobotGui\main.qml")))
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setTitle("UR Controller")
    if view.status() == QQuickView.Error:
        sys.exit(-1)
    view.show()

    root_obj = view.rootObject()
    view_model.init_connect(root_obj)
    root_obj.destroyed.connect(view_model.disconnectRobot)

    app.exec_()
    # Deleting the view before it goes out of scope is required to make
    # sure all child QML instances are destroyed in the correct order.
    del view
def main():
    # QApplication.setAttribute( Qt.AA_UseDesktopOpenGL )
    # QSurfaceFormat.setDefaultFormat(utils.defaultFormat(False)) # from vtk 8.2.0
    app = QGuiApplication(sys.argv)
    app.setApplicationName('QtVTK-Py')
    # qmlRegisterType(FboItem, "QmlVTK", 1, 0, "Interactor")
    qmlRegisterType(FboItem, "QtVTK", 1, 0, "VtkFboItem")

    view = QQuickView()  # qml file must begin with Item, not ApplicationWindow
    view.setSource(QUrl.fromLocalFile(abs_path("main.qml")))
    # view.setTitle ("QQuickView Load")
    # view.setResizeMode(QQuickView.SizeRootObjectToView)
    #    view.setFlags(Qt.FramelessWindowHint)
    view.show()
    '''
    In the unlikely event, you will encounter the following problems: the QML window is stuck.

    Please check if you: import pyside2, and use QmlApplicationEngine().load to load only one qml-vtk window(containing qmlRegisterType class) .
    If you have to do this, plus self.createRenderer () to __ init__ function, fboitem class.
    Then it works but an error window, vtkoutputwindow, will be displayed.
    Then try to close the vtkoutputwindow (maybe call the Win32 API findwindow?)

    Recommended solution: import PyQt5 instead of pyside2;
    Or using QQuickView().setSource to load qml window;
    Or load another independent general qml window before load the qml-vtk window.

    '''
    #    engine1 = QQmlApplicationEngine()  # qml file must begin with ApplicationWindow, not Item
    #    engine1.load(os.path.join(os.path.dirname(__file__), "main.qml")) # another independent general qml window

    #    engine = QQmlApplicationEngine()
    #    engine.load(os.path.join(os.path.dirname(__file__), "app.qml"))  # the qml-vtk window
    #    if not engine.rootObjects():
    #        sys.exit(-1)

    sys.exit(app.exec_())
Beispiel #31
0
from PySide2.QtCore import QUrl
from PySide2.QtQuick import QQuickView
from PySide2.QtWidgets import QApplication

app = QApplication([])
view = QQuickView()
url = QUrl("view.qml")

view.setSource(url)
view.show()
app.exec_()
Beispiel #32
0
class QTUI(UIBase):
    def xyToIndex(self, x, y):
        return y * 8 + x

    def indexToXY(self, index):
        return (index % 8, index // 8)

    def ioThread(self, inputQueue, emitter):
        while True:
            io = inputQueue.get()

            if (io["type"] == UIMessageType.SETUP):
                player = io["data"]["player_name"]
                emitter.sendName(player[WHITE], player[BLACK])
            elif (io["type"] == UIMessageType.BOARD):
                for index in range(0, 64):
                    col, row = self.indexToXY(index)
                    item = io["data"][row][col]
                    if (item == BLACK):
                        emitter.send(index, True)
                    elif (item == WHITE):
                        emitter.send(index, False)
                time.sleep(0.2)

            elif (io["type"] == UIMessageType.SCORE):
                emitter.sendScore(io["data"]["o"], io["data"]["x"])
            elif (io["type"] == UIMessageType.TURN):
                turn = io["data"]
                if turn == "x":
                    emitter.sendMark(True)
                else:
                    emitter.sendMark(False)
            elif (io["type"] == UIMessageType.FORFEIT):
                print("Tidak ada langkah mungkin, skip")
            elif (io["type"] == UIMessageType.DOTURN):
                pass
            elif (io["type"] == UIMessageType.QUIT):
                break

            self.inputQueue.task_done()

    def threadWorker(self):
        self.app = QGuiApplication()
        self.view = QQuickView()
        self.view.setResizeMode(QQuickView.SizeRootObjectToView)

        #Load the QML file
        qml_file = os.path.join(os.path.dirname(__file__), "view.qml")
        self.view.setSource(QUrl.fromLocalFile(os.path.abspath(qml_file)))

        root = self.view.rootObject()

        ioHandler = Handler(self.moveQueue)
        context = self.view.rootContext()
        context.setContextProperty("handler", ioHandler)

        #Show the window
        if self.view.status() == QQuickView.Error:
            sys.exit(-1)

        ioSignaler = ioObject(root)

        input_thread = threading.Thread(target=self.ioThread,
                                        args=(self.inputQueue, ioSignaler))
        input_thread.start()

        self.view.show()
        self.app.exec_()

        self.inputQueue.put({"type": UIMessageType.QUIT})
        input_thread.join()
        self.outputQueue.put({"type": UICommandType.QUIT})
        self.moveQueue.put({"x": -1, "y": -1})
Beispiel #33
0
## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
##
## $QT_END_LICENSE$
##
#############################################################################
"""PySide2 port of the QML Polar Chart Example from Qt v5.x"""

import sys
import os
from PySide2.QtQuick import QQuickView
from PySide2.QtCore import Qt, QUrl
from PySide2.QtWidgets import QApplication, QMainWindow

if __name__ == '__main__':
    app = QApplication(sys.argv)
    viewer = QQuickView()

    viewer.engine().addImportPath(os.path.dirname(__file__))
    viewer.engine().quit.connect(viewer.close)

    viewer.setTitle = "QML Polar Chart"
    qmlFile = os.path.join(os.path.dirname(__file__), 'main.qml')
    viewer.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile)))
    viewer.setResizeMode(QQuickView.SizeRootObjectToView)
    viewer.show()

    sys.exit(app.exec_())
Beispiel #34
0
from PySide2.QtWidgets import QApplication
from PySide2.QtQuick import QQuickView
from PySide2.QtCore import QUrl

app = QApplication([])
vista = QQuickView()
url = QUrl("vista.qml")

vista.setSource(url)
vista.show()
app.exec_()
Beispiel #35
0
        self._name = value

    colorChanged = Signal()
    color = Property(QColor, getColor, setColor, notify=colorChanged)
    name = Property(text_type, getName, setName)
    chartCleared = Signal()

    @Slot() # This should be something like @Invokable
    def clearChart(self):
        self.setColor(Qt.transparent)
        self.update()
        self.chartCleared.emit()

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

    qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart');

    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml')
    view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile)))
    if view.status() == QQuickView.Error:
        sys.exit(-1)
    view.show()
    res = app.exec_()
    # Deleting the view before it goes out of scope is required to make sure all child QML instances
    # are destroyed in the correct order.
    del view
    sys.exit(res)