diff options
| author | Christian Tismer <tismer@stackless.com> | 2021-02-08 16:47:54 +0100 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2021-02-10 14:40:20 +0100 |
| commit | 8ce4d053ceb0861b56305cdd2e001e864b02f9c2 (patch) | |
| tree | 6268bff542b81bb203bf4f5056665cb74fa4af8c /sources/pyside6/doc/tutorials/portingguide | |
| parent | ac7365aa78d78a3693c46e2177df3216d0a40628 (diff) | |
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 <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/doc/tutorials/portingguide')
| -rw-r--r-- | sources/pyside6/doc/tutorials/portingguide/chapter2/bookdelegate.py | 10 | ||||
| -rw-r--r-- | sources/pyside6/doc/tutorials/portingguide/chapter3/bookdelegate-old.py | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/sources/pyside6/doc/tutorials/portingguide/chapter2/bookdelegate.py b/sources/pyside6/doc/tutorials/portingguide/chapter2/bookdelegate.py index d6c16972b..bebb40f50 100644 --- a/sources/pyside6/doc/tutorials/portingguide/chapter2/bookdelegate.py +++ b/sources/pyside6/doc/tutorials/portingguide/chapter2/bookdelegate.py @@ -38,20 +38,24 @@ ## ############################################################################# -import copy, os +import copy +import os +from pathlib import Path + from PySide6.QtSql import QSqlRelationalDelegate from PySide6.QtWidgets import (QItemDelegate, QSpinBox, QStyledItemDelegate, QStyle, QStyleOptionViewItem) from PySide6.QtGui import QMouseEvent, QPixmap, QPalette, QImage from PySide6.QtCore import QEvent, QSize, Qt, QUrl + class BookDelegate(QSqlRelationalDelegate): """Books delegate to rate the books""" def __init__(self, parent=None): QSqlRelationalDelegate.__init__(self, parent) - star_png = os.path.dirname(__file__) + "\images\star.png" - self.star = QPixmap(star_png) + star_png = Path(__file__).parent / "images" / "star.png" + self.star = QPixmap(os.fspath(star_png)) def paint(self, painter, option, index): """ Paint the items in the table. diff --git a/sources/pyside6/doc/tutorials/portingguide/chapter3/bookdelegate-old.py b/sources/pyside6/doc/tutorials/portingguide/chapter3/bookdelegate-old.py index 0c0f1ee69..4b5009b32 100644 --- a/sources/pyside6/doc/tutorials/portingguide/chapter3/bookdelegate-old.py +++ b/sources/pyside6/doc/tutorials/portingguide/chapter3/bookdelegate-old.py @@ -38,20 +38,24 @@ ## ############################################################################# -import copy, os +import copy +import os +from pathlib import Path + from PySide6.QtSql import QSqlRelationalDelegate from PySide6.QtWidgets import (QItemDelegate, QSpinBox, QStyledItemDelegate, QStyle, QStyleOptionViewItem) from PySide6.QtGui import QMouseEvent, QPixmap, QPalette, QImage from PySide6.QtCore import QEvent, QSize, Qt, QUrl + class BookDelegate(QSqlRelationalDelegate): """Books delegate to rate the books""" def __init__(self, star_png, parent=None): QSqlRelationalDelegate.__init__(self, parent) - star_png = os.path.dirname(__file__) + "\images\star.png" - self.star = QPixmap(star_png) + star_png = Path(__file__).parent / "images" / "star.png" + self.star = QPixmap(os.fspath(star_png)) def paint(self, painter, option, index): """ Paint the items in the table. |
