From 8ce4d053ceb0861b56305cdd2e001e864b02f9c2 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Mon, 8 Feb 2021 16:47:54 +0100 Subject: Switch from os.path to pathlib.Path, all source changes but tests With this patch, os.path in Shiboken and Pyside will be completely removed from sources. The rest will be done later. Task-number: PYSIDE-1499 Change-Id: Id01782779487ceec62efdd1f32f65beee0234338 Reviewed-by: Friedemann Kleint --- sources/pyside6/doc/tutorials/qmlapp/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'sources/pyside6/doc/tutorials/qmlapp/main.py') diff --git a/sources/pyside6/doc/tutorials/qmlapp/main.py b/sources/pyside6/doc/tutorials/qmlapp/main.py index 5946538d9..c1c941835 100644 --- a/sources/pyside6/doc/tutorials/qmlapp/main.py +++ b/sources/pyside6/doc/tutorials/qmlapp/main.py @@ -41,12 +41,18 @@ #!/usr/bin/env python # -*- conding: utf-8 -*- -import os, sys, urllib.request, json +import os +import sys +import urllib.request +import json +from pathlib import Path + import PySide6.QtQml from PySide6.QtQuick import QQuickView from PySide6.QtCore import QStringListModel, Qt, QUrl from PySide6.QtGui import QGuiApplication + if __name__ == '__main__': #get our data @@ -66,11 +72,11 @@ if __name__ == '__main__': #Expose the list to the Qml code my_model = QStringListModel() my_model.setStringList(data_list) - view.rootContext().setContextProperty("myModel",my_model) + view.rootContext().setContextProperty("myModel", my_model) #Load the QML file - qml_file = os.path.join(os.path.dirname(__file__),"view.qml") - view.setSource(QUrl.fromLocalFile(os.path.abspath(qml_file))) + qml_file = Path(__file__).parent / "view.qml" + view.setSource(QUrl.fromLocalFile(os.fspath(qml_file.resolve()))) #Show the window if view.status() == QQuickView.Error: -- cgit v1.2.3