diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-03-23 13:22:37 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-03-23 16:52:02 +0100 |
commit | ea35d748ec16822a4b845e8e839ecd04f59ac763 (patch) | |
tree | b8ec29de751d26f03b39035327a51dd52c529b19 /examples/declarative/extending | |
parent | 83e70cc9914a814658bfe495c6092b70e166a905 (diff) |
Use pathlib in examples
Task-number: PYSIDE-1112
Change-Id: Ib99dbfb2c3889495d062b50dc9dbea04f1f78c79
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples/declarative/extending')
5 files changed, 15 insertions, 10 deletions
diff --git a/examples/declarative/extending/chapter1-basics/basics.py b/examples/declarative/extending/chapter1-basics/basics.py index 5e2614fc7..9cbead9cc 100644 --- a/examples/declarative/extending/chapter1-basics/basics.py +++ b/examples/declarative/extending/chapter1-basics/basics.py @@ -42,6 +42,7 @@ """PySide6 port of the qml/tutorials/extending-qml/chapter1-basics example from Qt v5.x""" import os +from pathlib import Path import sys from PySide6.QtCore import Property, Signal, Qt, QUrl @@ -88,8 +89,8 @@ if __name__ == '__main__': view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml') - view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile))) + qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml') + view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: sys.exit(-1) view.show() diff --git a/examples/declarative/extending/chapter2-methods/methods.py b/examples/declarative/extending/chapter2-methods/methods.py index 8b9c94c62..a37376ca8 100644 --- a/examples/declarative/extending/chapter2-methods/methods.py +++ b/examples/declarative/extending/chapter2-methods/methods.py @@ -42,6 +42,7 @@ """PySide6 port of the qml/tutorials/extending-qml/chapter2-methods example from Qt v5.x""" import os +from pathlib import Path import sys from PySide6.QtCore import Property, Signal, Slot, Qt, QUrl @@ -94,8 +95,8 @@ if __name__ == '__main__': view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml') - view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile))) + qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml') + view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: sys.exit(-1) view.show() diff --git a/examples/declarative/extending/chapter3-bindings/bindings.py b/examples/declarative/extending/chapter3-bindings/bindings.py index 474745652..d19df7f24 100644 --- a/examples/declarative/extending/chapter3-bindings/bindings.py +++ b/examples/declarative/extending/chapter3-bindings/bindings.py @@ -42,6 +42,7 @@ """PySide6 port of the qml/tutorials/extending-qml/chapter3-bindings example from Qt v5.x""" import os +from pathlib import Path import sys from PySide6.QtCore import Property, Signal, Slot, QUrl, Qt @@ -98,8 +99,8 @@ if __name__ == '__main__': view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml') - view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile))) + qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml') + view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: sys.exit(-1) view.show() diff --git a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py index 6a4be313e..1bf9387f5 100644 --- a/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py +++ b/examples/declarative/extending/chapter4-customPropertyTypes/customPropertyTypes.py @@ -42,6 +42,7 @@ """PySide6 port of the qml/tutorials/extending-qml/chapter4-customPropertyTypes example from Qt v5.x""" import os +from pathlib import Path import sys from PySide6.QtCore import Property, QUrl @@ -100,8 +101,8 @@ if __name__ == '__main__': view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml') - view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile))) + qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml') + view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: sys.exit(-1) view.show() diff --git a/examples/declarative/extending/chapter5-listproperties/listproperties.py b/examples/declarative/extending/chapter5-listproperties/listproperties.py index 37603ea12..646a14458 100644 --- a/examples/declarative/extending/chapter5-listproperties/listproperties.py +++ b/examples/declarative/extending/chapter5-listproperties/listproperties.py @@ -42,6 +42,7 @@ """PySide6 port of the qml/tutorials/extending-qml/chapter5-listproperties example from Qt v5.x""" import os +from pathlib import Path import sys from PySide6.QtCore import Property, QUrl @@ -114,8 +115,8 @@ if __name__ == '__main__': view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml') - view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile))) + qml_file = os.fspath(Path(__file__).resolve().parent / 'app.qml') + view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: sys.exit(-1) view.show() |