diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-03-22 15:41:48 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-03-22 19:41:03 +0000 |
commit | 570cc14c50782ed46393a0a6a8d9d491fbb3785a (patch) | |
tree | 9b123ff862fb83b2c70db4791792919ecc59bd47 /examples/widgets/tutorials | |
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 <tismer@stackless.com>
Diffstat (limited to 'examples/widgets/tutorials')
-rw-r--r-- | examples/widgets/tutorials/addressbook/part2.py | 4 | ||||
-rw-r--r-- | examples/widgets/tutorials/addressbook/part3.py | 4 | ||||
-rw-r--r-- | examples/widgets/tutorials/addressbook/part4.py | 14 | ||||
-rw-r--r-- | examples/widgets/tutorials/addressbook/part5.py | 16 | ||||
-rw-r--r-- | examples/widgets/tutorials/addressbook/part6.py | 20 | ||||
-rw-r--r-- | examples/widgets/tutorials/addressbook/part7.py | 22 | ||||
-rw-r--r-- | examples/widgets/tutorials/cannon/t10.py | 4 | ||||
-rw-r--r-- | examples/widgets/tutorials/cannon/t11.py | 4 | ||||
-rw-r--r-- | examples/widgets/tutorials/cannon/t12.py | 4 | ||||
-rw-r--r-- | examples/widgets/tutorials/cannon/t13.py | 4 | ||||
-rw-r--r-- | examples/widgets/tutorials/cannon/t14.py | 4 | ||||
-rw-r--r-- | examples/widgets/tutorials/cannon/t8.py | 6 | ||||
-rw-r--r-- | examples/widgets/tutorials/cannon/t9.py | 4 |
13 files changed, 55 insertions, 55 deletions
diff --git a/examples/widgets/tutorials/addressbook/part2.py b/examples/widgets/tutorials/addressbook/part2.py index 92254ce1c..68446d3d0 100644 --- a/examples/widgets/tutorials/addressbook/part2.py +++ b/examples/widgets/tutorials/addressbook/part2.py @@ -141,10 +141,10 @@ class AddressBook(QtWidgets.QWidget): if name not in self.contacts: self.contacts[name] = address QtWidgets.QMessageBox.information(self, "Add Successful", - "\"%s\" has been added to your address book." % name) + f'"{name}" has been added to your address book.') else: QtWidgets.QMessageBox.information(self, "Add Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return if not self.contacts: diff --git a/examples/widgets/tutorials/addressbook/part3.py b/examples/widgets/tutorials/addressbook/part3.py index c04b8f2b9..cfb150d7f 100644 --- a/examples/widgets/tutorials/addressbook/part3.py +++ b/examples/widgets/tutorials/addressbook/part3.py @@ -154,10 +154,10 @@ class AddressBook(QtWidgets.QWidget): if name not in self.contacts: self.contacts[name] = address QtWidgets.QMessageBox.information(self, "Add Successful", - "\"%s\" has been added to your address book." % name) + f'"{name}" has been added to your address book.') else: QtWidgets.QMessageBox.information(self, "Add Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return if not self.contacts: diff --git a/examples/widgets/tutorials/addressbook/part4.py b/examples/widgets/tutorials/addressbook/part4.py index eca0be852..dbca3c099 100644 --- a/examples/widgets/tutorials/addressbook/part4.py +++ b/examples/widgets/tutorials/addressbook/part4.py @@ -165,26 +165,26 @@ class AddressBook(QtWidgets.QWidget): if name not in self.contacts: self.contacts[name] = address QtWidgets.QMessageBox.information(self, "Add Successful", - "\"%s\" has been added to your address book." % name) + f'"{name}" has been added to your address book.') else: QtWidgets.QMessageBox.information(self, "Add Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.currentMode == self.EditingMode: if self.oldName != name: if name not in self.contacts: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % self.oldName) + f'"{self.oldName}" has been edited in your address book.') del self.contacts[self.oldName] self.contacts[name] = address else: QtWidgets.QMessageBox.information(self, "Edit Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.oldAddress != address: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % name) + f'"{name}" has been edited in your address book.') self.contacts[name] = address self.updateInterface(self.NavigationMode) @@ -200,7 +200,7 @@ class AddressBook(QtWidgets.QWidget): if name in self.contacts: button = QtWidgets.QMessageBox.question(self, "Confirm Remove", - "Are you sure you want to remove \"%s\"?" % name, + f'Are you sure you want to remove "{name}"?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if button == QtWidgets.QMessageBox.Yes: @@ -208,7 +208,7 @@ class AddressBook(QtWidgets.QWidget): del self.contacts[name] QtWidgets.QMessageBox.information(self, "Remove Successful", - "\"%s\" has been removed from your address book." % name) + f'"{name}" has been removed from your address book.') self.updateInterface(self.NavigationMode) diff --git a/examples/widgets/tutorials/addressbook/part5.py b/examples/widgets/tutorials/addressbook/part5.py index 27eb50a82..a513889ec 100644 --- a/examples/widgets/tutorials/addressbook/part5.py +++ b/examples/widgets/tutorials/addressbook/part5.py @@ -171,26 +171,26 @@ class AddressBook(QtWidgets.QWidget): if name not in self.contacts: self.contacts[name] = address QtWidgets.QMessageBox.information(self, "Add Successful", - "\"%s\" has been added to your address book." % name) + f'"{name}" has been added to your address book.') else: QtWidgets.QMessageBox.information(self, "Add Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.currentMode == self.EditingMode: if self.oldName != name: if name not in self.contacts: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % self.oldName) + f'"{self.oldName}" has been edited in your address book.') del self.contacts[self.oldName] self.contacts[name] = address else: QtWidgets.QMessageBox.information(self, "Edit Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.oldAddress != address: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % name) + f'"{name}" has been edited in your address book.') self.contacts[name] = address self.updateInterface(self.NavigationMode) @@ -206,7 +206,7 @@ class AddressBook(QtWidgets.QWidget): if name in self.contacts: button = QtWidgets.QMessageBox.question(self, "Confirm Remove", - "Are you sure you want to remove \"%s\"?" % name, + f'Are you sure you want to remove "{name}"?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if button == QtWidgets.QMessageBox.Yes: @@ -214,7 +214,7 @@ class AddressBook(QtWidgets.QWidget): del self.contacts[name] QtWidgets.QMessageBox.information(self, "Remove Successful", - "\"%s\" has been removed from your address book." % name) + f'"{name}" has been removed from your address book.') self.updateInterface(self.NavigationMode) @@ -268,7 +268,7 @@ class AddressBook(QtWidgets.QWidget): self.addressText.setText(self.contacts[contactName]) else: QtWidgets.QMessageBox.information(self, "Contact Not Found", - "Sorry, \"%s\" is not in your address book." % contactName) + f'Sorry, "{contactName}" is not in your address book.') return self.updateInterface(self.NavigationMode) diff --git a/examples/widgets/tutorials/addressbook/part6.py b/examples/widgets/tutorials/addressbook/part6.py index 70103380c..370c1ba9c 100644 --- a/examples/widgets/tutorials/addressbook/part6.py +++ b/examples/widgets/tutorials/addressbook/part6.py @@ -183,26 +183,26 @@ class AddressBook(QtWidgets.QWidget): if name not in self.contacts: self.contacts[name] = address QtWidgets.QMessageBox.information(self, "Add Successful", - "\"%s\" has been added to your address book." % name) + f'"{name}" has been added to your address book.') else: QtWidgets.QMessageBox.information(self, "Add Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.currentMode == self.EditingMode: if self.oldName != name: if name not in self.contacts: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % self.oldName) + f'"{self.oldName}" has been edited in your address book.') del self.contacts[self.oldName] self.contacts[name] = address else: QtWidgets.QMessageBox.information(self, "Edit Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.oldAddress != address: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % name) + f'"{name}" has been edited in your address book.') self.contacts[name] = address self.updateInterface(self.NavigationMode) @@ -218,7 +218,7 @@ class AddressBook(QtWidgets.QWidget): if name in self.contacts: button = QtWidgets.QMessageBox.question(self, "Confirm Remove", - "Are you sure you want to remove \"%s\"?" % name, + f'Are you sure you want to remove "{name}"?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if button == QtWidgets.QMessageBox.Yes: @@ -226,7 +226,7 @@ class AddressBook(QtWidgets.QWidget): del self.contacts[name] QtWidgets.QMessageBox.information(self, "Remove Successful", - "\"%s\" has been removed from your address book." % name) + f'"{name}" has been removed from your address book.') self.updateInterface(self.NavigationMode) @@ -280,7 +280,7 @@ class AddressBook(QtWidgets.QWidget): self.addressText.setText(self.contacts[contactName]) else: QtWidgets.QMessageBox.information(self, "Contact Not Found", - "Sorry, \"%s\" is not in your address book." % contactName) + f'Sorry, "{contactName}" is not in your address book.') return self.updateInterface(self.NavigationMode) @@ -340,7 +340,7 @@ class AddressBook(QtWidgets.QWidget): out_file = open(str(fileName), 'wb') except IOError: QtWidgets.QMessageBox.information(self, "Unable to open file", - "There was an error opening \"%s\"" % fileName) + f'There was an error opening "{fileName}"') return pickle.dump(self.contacts, out_file) @@ -358,7 +358,7 @@ class AddressBook(QtWidgets.QWidget): in_file = open(str(fileName), 'rb') except IOError: QtWidgets.QMessageBox.information(self, "Unable to open file", - "There was an error opening \"%s\"" % fileName) + f'There was an error opening "{fileName}"') return self.contacts = pickle.load(in_file) diff --git a/examples/widgets/tutorials/addressbook/part7.py b/examples/widgets/tutorials/addressbook/part7.py index c6a272636..d2c70d41a 100644 --- a/examples/widgets/tutorials/addressbook/part7.py +++ b/examples/widgets/tutorials/addressbook/part7.py @@ -189,26 +189,26 @@ class AddressBook(QtWidgets.QWidget): if name not in self.contacts: self.contacts[name] = address QtWidgets.QMessageBox.information(self, "Add Successful", - "\"%s\" has been added to your address book." % name) + f'"{name}" has been added to your address book.') else: QtWidgets.QMessageBox.information(self, "Add Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.currentMode == self.EditingMode: if self.oldName != name: if name not in self.contacts: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % self.oldName) + f'"{self.oldName}" has been edited in your address book.') del self.contacts[self.oldName] self.contacts[name] = address else: QtWidgets.QMessageBox.information(self, "Edit Unsuccessful", - "Sorry, \"%s\" is already in your address book." % name) + f'Sorry, "{name}" is already in your address book.') return elif self.oldAddress != address: QtWidgets.QMessageBox.information(self, "Edit Successful", - "\"%s\" has been edited in your address book." % name) + f'"{name}" has been edited in your address book.') self.contacts[name] = address self.updateInterface(self.NavigationMode) @@ -224,7 +224,7 @@ class AddressBook(QtWidgets.QWidget): if name in self.contacts: button = QtWidgets.QMessageBox.question(self, "Confirm Remove", - "Are you sure you want to remove \"%s\"?" % name, + f'Are you sure you want to remove "{name}"?', QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) if button == QtWidgets.QMessageBox.Yes: @@ -232,7 +232,7 @@ class AddressBook(QtWidgets.QWidget): del self.contacts[name] QtWidgets.QMessageBox.information(self, "Remove Successful", - "\"%s\" has been removed from your address book." % name) + f'"{name}" has been removed from your address book.') self.updateInterface(self.NavigationMode) @@ -286,7 +286,7 @@ class AddressBook(QtWidgets.QWidget): self.addressText.setText(self.contacts[contactName]) else: QtWidgets.QMessageBox.information(self, "Contact Not Found", - "Sorry, \"%s\" is not in your address book." % contactName) + f'Sorry, "{contactName}" is not in your address book.') return self.updateInterface(self.NavigationMode) @@ -349,7 +349,7 @@ class AddressBook(QtWidgets.QWidget): out_file = open(str(fileName), 'wb') except IOError: QtWidgets.QMessageBox.information(self, "Unable to open file", - "There was an error opening \"%s\"" % fileName) + f'There was an error opening "{fileName}"') return pickle.dump(self.contacts, out_file) @@ -367,7 +367,7 @@ class AddressBook(QtWidgets.QWidget): in_file = open(str(fileName), 'rb') except IOError: QtWidgets.QMessageBox.information(self, "Unable to open file", - "There was an error opening \"%s\"" % fileName) + f'There was an error opening "{fileName}"') return self.contacts = pickle.load(in_file) @@ -425,7 +425,7 @@ class AddressBook(QtWidgets.QWidget): out_s << 'END:VCARD' << '\n' QtWidgets.QMessageBox.information(self, "Export Successful", - "\"%s\" has been exported as a vCard." % name) + f'"{name}" has been exported as a vCard.') class FindDialog(QtWidgets.QDialog): diff --git a/examples/widgets/tutorials/cannon/t10.py b/examples/widgets/tutorials/cannon/t10.py index ca7e9d9b7..1cfed53aa 100644 --- a/examples/widgets/tutorials/cannon/t10.py +++ b/examples/widgets/tutorials/cannon/t10.py @@ -77,9 +77,9 @@ class LCDRange(QtWidgets.QWidget): def setRange(self, minValue, maxValue): if minValue < 0 or maxValue > 99 or minValue > maxValue: - QtCore.qWarning("LCDRange::setRange(%d, %d)\n" + QtCore.qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n" "\tRange must be 0..99\n" - "\tand minValue must not be greater than maxValue" % (minValue, maxValue)) + "\tand minValue must not be greater than maxValue") return self.slider.setRange(minValue, maxValue) diff --git a/examples/widgets/tutorials/cannon/t11.py b/examples/widgets/tutorials/cannon/t11.py index c3d2e1271..dfc206d51 100644 --- a/examples/widgets/tutorials/cannon/t11.py +++ b/examples/widgets/tutorials/cannon/t11.py @@ -78,9 +78,9 @@ class LCDRange(QtWidgets.QWidget): def setRange(self, minValue, maxValue): if minValue < 0 or maxValue > 99 or minValue > maxValue: - QtCore.qWarning("LCDRange::setRange(%d, %d)\n" + QtCore.qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n" "\tRange must be 0..99\n" - "\tand minValue must not be greater than maxValue" % (minValue, maxValue)) + "\tand minValue must not be greater than maxValue") return self.slider.setRange(minValue, maxValue) diff --git a/examples/widgets/tutorials/cannon/t12.py b/examples/widgets/tutorials/cannon/t12.py index 290ecc82e..b94a28688 100644 --- a/examples/widgets/tutorials/cannon/t12.py +++ b/examples/widgets/tutorials/cannon/t12.py @@ -95,9 +95,9 @@ class LCDRange(QtWidgets.QWidget): def setRange(self, minValue, maxValue): if minValue < 0 or maxValue > 99 or minValue > maxValue: - QtCore.qWarning("LCDRange::setRange(%d, %d)\n" + QtCore.qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n" "\tRange must be 0..99\n" - "\tand minValue must not be greater than maxValue" % (minValue, maxValue)) + "\tand minValue must not be greater than maxValue") return self.slider.setRange(minValue, maxValue) diff --git a/examples/widgets/tutorials/cannon/t13.py b/examples/widgets/tutorials/cannon/t13.py index b54945e25..467346c2c 100644 --- a/examples/widgets/tutorials/cannon/t13.py +++ b/examples/widgets/tutorials/cannon/t13.py @@ -96,9 +96,9 @@ class LCDRange(QtWidgets.QWidget): def setRange(self, minValue, maxValue): if minValue < 0 or maxValue > 99 or minValue > maxValue: - QtCore.qWarning("LCDRange::setRange(%d, %d)\n" + QtCore.qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n" "\tRange must be 0..99\n" - "\tand minValue must not be greater than maxValue" % (minValue, maxValue)) + "\tand minValue must not be greater than maxValue") return self.slider.setRange(minValue, maxValue) diff --git a/examples/widgets/tutorials/cannon/t14.py b/examples/widgets/tutorials/cannon/t14.py index 19fb95ac8..420eeaa08 100644 --- a/examples/widgets/tutorials/cannon/t14.py +++ b/examples/widgets/tutorials/cannon/t14.py @@ -96,9 +96,9 @@ class LCDRange(QtWidgets.QWidget): def setRange(self, minValue, maxValue): if minValue < 0 or maxValue > 99 or minValue > maxValue: - QtCore.qWarning("LCDRange::setRange(%d, %d)\n" + QtCore.qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n" "\tRange must be 0..99\n" - "\tand minValue must not be greater than maxValue" % (minValue, maxValue)) + "\tand minValue must not be greater than maxValue") return self.slider.setRange(minValue, maxValue) diff --git a/examples/widgets/tutorials/cannon/t8.py b/examples/widgets/tutorials/cannon/t8.py index 3761b4353..e2d013eca 100644 --- a/examples/widgets/tutorials/cannon/t8.py +++ b/examples/widgets/tutorials/cannon/t8.py @@ -77,9 +77,9 @@ class LCDRange(QtWidgets.QWidget): def setRange(self, minValue, maxValue): if minValue < 0 or maxValue > 99 or minValue > maxValue: - QtCore.qWarning("LCDRange.setRange(%d, %d)\n" + QtCore.qWarning("LCDRange.setRange({minValue}, {maxValue})\n" "\tRange must be 0..99\n" - "\tand minValue must not be greater than maxValue" % (minValue, maxValue)) + "\tand minValue must not be greater than maxValue") return self.slider.setRange(minValue, maxValue) @@ -111,7 +111,7 @@ class CannonField(QtWidgets.QWidget): def paintEvent(self, event): painter = QtGui.QPainter(self) - painter.drawText(200, 200, "Angle = %d" % self.currentAngle) + painter.drawText(200, 200, f"Angle = {self.currentAngle}") class MyWidget(QtWidgets.QWidget): diff --git a/examples/widgets/tutorials/cannon/t9.py b/examples/widgets/tutorials/cannon/t9.py index ca949c1ac..6d743357d 100644 --- a/examples/widgets/tutorials/cannon/t9.py +++ b/examples/widgets/tutorials/cannon/t9.py @@ -77,9 +77,9 @@ class LCDRange(QtWidgets.QWidget): def setRange(self, minValue, maxValue): if minValue < 0 or maxValue > 99 or minValue > maxValue: - QtCore.qWarning("LCDRange::setRange(%d, %d)\n" + QtCore.qWarning(f"LCDRange::setRange({minValue}, {maxValue})\n" "\tRange must be 0..99\n" - "\tand minValue must not be greater than maxValue" % (minValue, maxValue)) + "\tand minValue must not be greater than maxValue") return self.slider.setRange(minValue, maxValue) |