First, let's have a look at the typical boiler plate code for loading a .qml file. We instantiate a QGuiApplication and a QQuickView. We set its resize mode property to SizeRootObjectToView so that the QML element is expanded to the view size.
We then instruct the view to load the QML file, using the method setSource. Since a QML file typically is to be found next to the Python script, we construct a complete path using functions of the os module: