diff options
author | Friedemann Kleint <[email protected]> | 2021-03-22 15:41:48 +0100 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2021-03-22 19:41:03 +0000 |
commit | 570cc14c50782ed46393a0a6a8d9d491fbb3785a (patch) | |
tree | 9b123ff862fb83b2c70db4791792919ecc59bd47 /examples/widgets/mainwindows/application | |
parent | 80aec29aca246f1f67a4f8c453b49f1eadfee6fd (diff) |
Replace % formatting in examples by f-strings
As drive-by, Fix fortune server, addressbook and dombookmarks examples to work.
Task-number: PYSIDE-1112
Change-Id: I8ef7759ed56aeb7157cf2222bee9b6481973112a
Reviewed-by: Christian Tismer <[email protected]>
Diffstat (limited to 'examples/widgets/mainwindows/application')
-rw-r--r-- | examples/widgets/mainwindows/application/application.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/widgets/mainwindows/application/application.py b/examples/widgets/mainwindows/application/application.py index 4fddff5c1..93500efe1 100644 --- a/examples/widgets/mainwindows/application/application.py +++ b/examples/widgets/mainwindows/application/application.py @@ -216,8 +216,9 @@ class MainWindow(QtWidgets.QMainWindow): def loadFile(self, fileName): file = QtCore.QFile(fileName) if not file.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text): + reason = file.errorString() QtWidgets.QMessageBox.warning(self, "Application", - "Cannot read file %s:\n%s." % (fileName, file.errorString())) + f"Cannot read file {fileName}:\n{reason}.") return inf = QtCore.QTextStream(file) @@ -236,9 +237,11 @@ class MainWindow(QtWidgets.QMainWindow): outf = QtCore.QTextStream(file) outf << self.textEdit.toPlainText() if not file.commit(): - error = "Cannot write file %s:\n%s." % (fileName, file.errorString()) + reason = file.errorString() + error = f"Cannot write file {fileName}:\n{reason}." else: - error = "Cannot open file %s:\n%s." % (fileName, file.errorString()) + reason = file.errorString() + error = f"Cannot open file {fileName}:\n{reason}." QtWidgets.QApplication.restoreOverrideCursor() if error: @@ -259,7 +262,7 @@ class MainWindow(QtWidgets.QMainWindow): else: shownName = 'untitled.txt' - self.setWindowTitle("%s[*] - Application" % shownName) + self.setWindowTitle(f"{shownName}[*] - Application") def strippedName(self, fullFileName): return QtCore.QFileInfo(fullFileName).fileName() |