diff options
| author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-01-04 21:03:22 +0100 |
|---|---|---|
| committer | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-01-06 14:51:48 +0100 |
| commit | d9f344fcef6bec04a787f9ea9f4ea94f15eaa26c (patch) | |
| tree | 212261cffc6086e77a9731f3e23e8d12e6715b5e /sources/pyside6/doc/tutorials/datavisualize | |
| parent | b6d1b76b46d7b756f7cb01361037e1cb5efc990a (diff) | |
sources: migration from format() to f-strings
This should be the last patch related the usage of f-strings
from the 'sources' directory.
Pick-to: 6.0
Change-Id: I0288d720dc4930dee088ca3396a66d1b3ba18f76
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/doc/tutorials/datavisualize')
4 files changed, 14 insertions, 13 deletions
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py index d9c50acb3..3ccf8162b 100644 --- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py +++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py @@ -66,7 +66,7 @@ class CustomTableModel(QAbstractTableModel): if orientation == Qt.Horizontal: return ("Date", "Magnitude")[section] else: - return "{}".format(section) + return f"{section}" def data(self, index, role=Qt.DisplayRole): column = index.column() @@ -74,11 +74,11 @@ class CustomTableModel(QAbstractTableModel): if role == Qt.DisplayRole: if column == 0: - raw_date = self.input_dates[row] - date = "{}".format(raw_date.toPython()) + date = self.input_dates[row].toPython() return date[:-3] elif column == 1: - return "{:.2f}".format(self.input_magnitudes[row]) + magnitude = self.input_magnitudes[row] + return f"{magnitude:.2f}" elif role == Qt.BackgroundRole: return QColor(Qt.white) elif role == Qt.TextAlignmentRole: diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py index d9c50acb3..3ccf8162b 100644 --- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py +++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py @@ -66,7 +66,7 @@ class CustomTableModel(QAbstractTableModel): if orientation == Qt.Horizontal: return ("Date", "Magnitude")[section] else: - return "{}".format(section) + return f"{section}" def data(self, index, role=Qt.DisplayRole): column = index.column() @@ -74,11 +74,11 @@ class CustomTableModel(QAbstractTableModel): if role == Qt.DisplayRole: if column == 0: - raw_date = self.input_dates[row] - date = "{}".format(raw_date.toPython()) + date = self.input_dates[row].toPython() return date[:-3] elif column == 1: - return "{:.2f}".format(self.input_magnitudes[row]) + magnitude = self.input_magnitudes[row] + return f"{magnitude:.2f}" elif role == Qt.BackgroundRole: return QColor(Qt.white) elif role == Qt.TextAlignmentRole: diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py index 2934a361f..d8132265d 100644 --- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py +++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py @@ -127,5 +127,6 @@ class Widget(QWidget): self.series.attachAxis(self.axis_y) # Getting the color from the QChart to use it on the QTableView - self.model.color = "{}".format(self.series.pen().color().name()) + color_name = self.series.pen().color().name() + self.model.color = f"{color_name}" diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py index abe3bf2ae..f46d5d402 100644 --- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py +++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py @@ -67,7 +67,7 @@ class CustomTableModel(QAbstractTableModel): if orientation == Qt.Horizontal: return ("Date", "Magnitude")[section] else: - return "{}".format(section) + return f"{section}" def data(self, index, role=Qt.DisplayRole): column = index.column() @@ -75,11 +75,11 @@ class CustomTableModel(QAbstractTableModel): if role == Qt.DisplayRole: if column == 0: - raw_date = self.input_dates[row] - date = "{}".format(raw_date.toPython()) + date = self.input_dates[row].toPython() return date[:-3] elif column == 1: - return "{:.2f}".format(self.input_magnitudes[row]) + magnitude = self.input_magnitudes[row] + return f"{magnitude:.2f}" elif role == Qt.BackgroundRole: return (QColor(Qt.white), QColor(self.color))[column] elif role == Qt.TextAlignmentRole: |
