From 2f5407838c73b59026c536574ef583d22c4f8627 Mon Sep 17 00:00:00 2001 From: David-Billingsley <5779556+David-Billingsley@users.noreply.github.com> Date: Thu, 12 Mar 2020 18:43:18 -0700 Subject: [PATCH 01/18] Fixed CSV file Save Added newline='' to print a remove the new line that was being created at the end of each saved row in the CSV file. --- Chapter05/csv_editor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Chapter05/csv_editor.py b/Chapter05/csv_editor.py index 952ff84..71215c0 100644 --- a/Chapter05/csv_editor.py +++ b/Chapter05/csv_editor.py @@ -85,7 +85,9 @@ def removeRows(self, position, rows, parent): # method for saving def save_data(self): - with open(self.filename, 'w', encoding='utf-8') as fh: + # commented out code below to fix issue with additional lines being added after saving csv file from the window. + # with open(self.filename, 'w', encoding='utf-8') as fh: + with open(self.filename, 'w', newline='', encoding='utf-8') as fh: writer = csv.writer(fh) writer.writerow(self._headers) writer.writerows(self._data) From 565b8e32e6d3104f60a464fe82e80ea3483a7cfd Mon Sep 17 00:00:00 2001 From: Alan D Moore Date: Thu, 26 Mar 2020 10:45:00 -0500 Subject: [PATCH 02/18] Fix incorrect calls to QMessageBox.critical As noted in issue #14, QMessageBox is called incorrectly, resulting in an exception. This change addresses the issue. --- Chapter04/text_editor.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Chapter04/text_editor.py b/Chapter04/text_editor.py index 7060569..15b16b1 100644 --- a/Chapter04/text_editor.py +++ b/Chapter04/text_editor.py @@ -269,7 +269,10 @@ def openFile(self): with open(filename, 'r') as fh: self.textedit.setText(fh.read()) except Exception as e: - qtw.QMessageBox.critical(f"Could not load file: {e}") + # Errata: Book contains the following line: + #qtw.QMessageBox.critical(f"Could not load file: {e}") + # It should read like this: + qtw.QMessageBox.critical(self, f"Could not load file: {e}") def saveFile(self): filename, _ = qtw.QFileDialog.getSaveFileName( @@ -283,7 +286,10 @@ def saveFile(self): with open(filename, 'w') as fh: fh.write(self.textedit.toPlainText()) except Exception as e: - qtw.QMessageBox.critical(f"Could not save file: {e}") + # Errata: Book contains this line: + #qtw.QMessageBox.critical(f"Could not save file: {e}") + # It should read like this: + qtw.QMessageBox.critical(self, f"Could not load file: {e}") def set_font(self): current = self.textedit.currentFont() From b70c5f20cc152ff4151f63c7db5414b808d85b38 Mon Sep 17 00:00:00 2001 From: Alan D Moore Date: Thu, 26 Mar 2020 10:50:10 -0500 Subject: [PATCH 03/18] Use self.close rather than self.destroy for quit action Fixes a problem where window hangs on quit. Closes #12. --- Chapter03/calendar_app.py | 5 ++++- Chapter04/text_editor.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Chapter03/calendar_app.py b/Chapter03/calendar_app.py index 554b604..837ff06 100644 --- a/Chapter03/calendar_app.py +++ b/Chapter03/calendar_app.py @@ -27,7 +27,10 @@ def __init__(self): self.layout().addWidget(self.submit_btn) self.cancel_btn = qtw.QPushButton( 'Cancel', - clicked=self.destroy + # Errata: The book contains this line: + #clicked=self.destroy + # It should call self.close instead, like so: + clicked=self.close ) self.layout().addWidget(self.cancel_btn) self.show() diff --git a/Chapter04/text_editor.py b/Chapter04/text_editor.py index 15b16b1..8e7698b 100644 --- a/Chapter04/text_editor.py +++ b/Chapter04/text_editor.py @@ -94,7 +94,10 @@ def __init__(self): file_menu.addSeparator() # add an action with a callback - quit_action = file_menu.addAction('Quit', self.destroy) + # Errata: The book contains this line: + #quit_action = file_menu.addAction('Quit', self.destroy) + # It should call self.close instead, like so: + quit_action = file_menu.addAction('Quit', self.close) # connect to a Qt Slot edit_menu.addAction('Undo', self.textedit.undo) From fe728b6b399136e1578e35ae9f97c0e15035a872 Mon Sep 17 00:00:00 2001 From: Alan D Moore Date: Thu, 26 Mar 2020 10:55:02 -0500 Subject: [PATCH 04/18] Correctly calculate number of csv rows to delete CSV Editor would delete too many rows if multiple columns where selected. This fix correctly calculates how many rows are selected when deleting rows. Fixes #13 --- Chapter05/csv_editor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Chapter05/csv_editor.py b/Chapter05/csv_editor.py index 952ff84..e23e59f 100644 --- a/Chapter05/csv_editor.py +++ b/Chapter05/csv_editor.py @@ -152,8 +152,17 @@ def insert_below(self): def remove_rows(self): selected = self.tableview.selectedIndexes() + # Errata: The book contains the following code: + #if selected: + # self.model.removeRows(selected[0].row(), len(selected), None) + + # This is incorrect, as len(selected) is the number of *cells* selected, + # not the number of *rows* selected. + + # correct approach would look like this: + num_rows = len(set(index.row() for index in selected)) if selected: - self.model.removeRows(selected[0].row(), len(selected), None) + self.model.removeRows(selected[0].row(), num_rows, None) if __name__ == '__main__': From ff8ef136d56394d70edd01ef7b13d8719fd8803e Mon Sep 17 00:00:00 2001 From: Alan D Moore Date: Thu, 26 Mar 2020 11:14:31 -0500 Subject: [PATCH 05/18] Fix problem in print dialog Fix problem where opening the print dialog immediately starts printing. (Thanks DevinLand). Closes #8 --- Chapter11/invoice_maker_printable.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Chapter11/invoice_maker_printable.py b/Chapter11/invoice_maker_printable.py index 43068fb..12ec06d 100644 --- a/Chapter11/invoice_maker_printable.py +++ b/Chapter11/invoice_maker_printable.py @@ -259,8 +259,14 @@ def _print_document(self): self.preview.document().print(self.printer) def print_dialog(self): - self._print_document() + # Errata: the book contained this line: + #self._print_document() + # As noted by DevinLand in issue #8, this can cause the document to start printing. dialog = qtps.QPrintDialog(self.printer, self) + + # Instead we'll add this line, so _print_document is triggered when the dialog is + # accepted: + dialog.accepted.connect(self._print_document) dialog.exec() self._update_preview_size() From 54143744ac2ac4f2b26478d2d08a208245be9b18 Mon Sep 17 00:00:00 2001 From: packt-pradeeps <45961039+packt-pradeeps@users.noreply.github.com> Date: Tue, 12 May 2020 14:52:51 +0530 Subject: [PATCH 06/18] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 1f2a6f9..6563b74 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,12 @@ We also provide a PDF file that has color images of the screenshots/diagrams use Click on the following link to see the Code in Action: [Click here to view the videos](http://bit.ly/2M3QVrl) +## Errata + +Page 77: The section of code that describes the "on_category_change" method: +* Line 3 reads, "dialog = CategoryWindow()", it should read, "self.dialog = CategoryWindow()" +* Line 4 reads, "dialog.submitted.connect(self.add_category)", it should read, "self.dialog.submitted.connect(self.add_category)" + ### Related products * Qt5 Python GUI Programming Cookbook [[Packt]](https://www.packtpub.com/application-development/qt5-python-gui-programming-cookbook?utm_source=github&utm_medium=repository&utm_campaign=) [[Amazon]](https://www.amazon.com/dp/B079S4Q9T2) From c973359b276b24261209be0211fc4eb4ebbf4b64 Mon Sep 17 00:00:00 2001 From: Alan Moore Date: Tue, 12 May 2020 22:18:19 -0500 Subject: [PATCH 07/18] Correct main script name in executable. Fixes #15 --- Chapter17/QTicTacToe/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter17/QTicTacToe/README.rst b/Chapter17/QTicTacToe/README.rst index c2d8ef4..c111eed 100644 --- a/Chapter17/QTicTacToe/README.rst +++ b/Chapter17/QTicTacToe/README.rst @@ -14,7 +14,7 @@ This is the classic game of **tic-tac-toe**, also known as noughts and crosses. Usage ===== -Simply run `python qtictactoe.py` from within the project folder. +Simply run `python run.py` from within the project folder. - Players take turns clicking the mouse on the playing field to mark squares. - When one player gets 3 in a row, they win. From 66f33ff6c07b7e22a396a982a5502bd93c20d785 Mon Sep 17 00:00:00 2001 From: Alan Moore Date: Thu, 23 Jul 2020 09:18:21 -0500 Subject: [PATCH 08/18] Unset current row of event list before clearing it. Closes #16. Thanks eramey16! --- Chapter03/calendar_app.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Chapter03/calendar_app.py b/Chapter03/calendar_app.py index 837ff06..1a1540a 100644 --- a/Chapter03/calendar_app.py +++ b/Chapter03/calendar_app.py @@ -146,6 +146,11 @@ def clear_form(self): self.event_detail.setPlainText('') def populate_list(self): + # As reported by github user eramey16, we need the following line + # to unselect list items since the selected index may not exist + # in the new list. This line is not in the book code. + self.event_list.setCurrentRow(-1) + self.event_list.clear() self.clear_form() date = self.calendar.selectedDate() From f26ebea214a3ccc8bb00cc3c63a5183e01662b0b Mon Sep 17 00:00:00 2001 From: Packt-ITService <62882280+Packt-ITService@users.noreply.github.com> Date: Mon, 14 Dec 2020 14:00:21 +0000 Subject: [PATCH 09/18] add $5 campaign --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6563b74..f2543eb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +## $5 Tech Unlocked 2021! +[Buy and download this Book for only $5 on PacktPub.com](https://www.packtpub.com/product/mastering-gui-programming-with-python/9781789612905) +----- +*If you have read this book, please leave a review on [Amazon.com](https://www.amazon.com/gp/product/178961290X). Potential readers can then use your unbiased opinion to help them make purchase decisions. Thank you. The $5 campaign runs from __December 15th 2020__ to __January 13th 2021.__* + # Mastering GUI Programming with Python Mastering GUI Programming with Python From f5086dd50f82fc06ef6552bca46f1bfcb3d4794a Mon Sep 17 00:00:00 2001 From: Packt-ITService <62882280+Packt-ITService@users.noreply.github.com> Date: Tue, 15 Dec 2020 12:22:29 +0000 Subject: [PATCH 10/18] add $5 campaign From 9aaddfe9cc7a4949ed759550d4dfb0238f064cf0 Mon Sep 17 00:00:00 2001 From: Packt-ITService <62882280+Packt-ITService@users.noreply.github.com> Date: Mon, 18 Jan 2021 06:39:08 +0000 Subject: [PATCH 11/18] remove $5 campaign --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index f2543eb..6563b74 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,3 @@ -## $5 Tech Unlocked 2021! -[Buy and download this Book for only $5 on PacktPub.com](https://www.packtpub.com/product/mastering-gui-programming-with-python/9781789612905) ------ -*If you have read this book, please leave a review on [Amazon.com](https://www.amazon.com/gp/product/178961290X). Potential readers can then use your unbiased opinion to help them make purchase decisions. Thank you. The $5 campaign runs from __December 15th 2020__ to __January 13th 2021.__* - # Mastering GUI Programming with Python Mastering GUI Programming with Python From f5f74660309dcb0adb029496fa9c858dd374098b Mon Sep 17 00:00:00 2001 From: Mani Date: Tue, 28 Sep 2021 17:01:20 +0530 Subject: [PATCH 12/18] Errata updated --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6563b74..b8dd5ea 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,12 @@ Page 77: The section of code that describes the "on_category_change" method: * Line 3 reads, "dialog = CategoryWindow()", it should read, "self.dialog = CategoryWindow()" * Line 4 reads, "dialog.submitted.connect(self.add_category)", it should read, "self.dialog.submitted.connect(self.add_category)" +Page 418: +* Here is the ```=__init__()``` method _should be_ Here is the ```__init__()``` method + +Page 419: +* The ```mousePressEvent())``` method is called _should be_ The ```mousePressEvent()``` method is called + ### Related products * Qt5 Python GUI Programming Cookbook [[Packt]](https://www.packtpub.com/application-development/qt5-python-gui-programming-cookbook?utm_source=github&utm_medium=repository&utm_campaign=) [[Amazon]](https://www.amazon.com/dp/B079S4Q9T2) From bf1e5a549f51b564d2a42d1056e78c0e2f57a5b9 Mon Sep 17 00:00:00 2001 From: packtutkarshr <48279450+packtutkarshr@users.noreply.github.com> Date: Fri, 27 May 2022 07:33:08 +0530 Subject: [PATCH 13/18] add $10 campaign --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b8dd5ea..41385a6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +## [Get this title for $10 on Packt's Spring Sale](https://www.packt.com/B12831?utm_source=github&utm_medium=packt-github-repo&utm_campaign=spring_10_dollar_2022) +----- +For a limited period, all eBooks and Videos are only $10. All the practical content you need \- by developers, for developers + # Mastering GUI Programming with Python Mastering GUI Programming with Python From 4dab2db96c054084ccae6785f26b5c82c9c98d08 Mon Sep 17 00:00:00 2001 From: packtutkarshr <48279450+packtutkarshr@users.noreply.github.com> Date: Fri, 27 May 2022 11:51:34 +0530 Subject: [PATCH 14/18] add $10 campaign From 9beddfbef7fa5be104aa04dd59d27c5278fe9156 Mon Sep 17 00:00:00 2001 From: packtutkarshr <48279450+packtutkarshr@users.noreply.github.com> Date: Tue, 14 Jun 2022 09:24:49 +0530 Subject: [PATCH 15/18] remove $10 campaign --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 41385a6..b8dd5ea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -## [Get this title for $10 on Packt's Spring Sale](https://www.packt.com/B12831?utm_source=github&utm_medium=packt-github-repo&utm_campaign=spring_10_dollar_2022) ------ -For a limited period, all eBooks and Videos are only $10. All the practical content you need \- by developers, for developers - # Mastering GUI Programming with Python Mastering GUI Programming with Python From 5bacbc1d769a014af97ee224093781bbe8daea0b Mon Sep 17 00:00:00 2001 From: Packt-ITService <62882280+Packt-ITService@users.noreply.github.com> Date: Fri, 21 Oct 2022 09:51:39 +0100 Subject: [PATCH 16/18] add free ebook notification --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b8dd5ea..1a95bc8 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,7 @@ is a data analyst and software developer who has been solving problems with Pyth [Click here](https://docs.google.com/forms/d/e/1FAIpQLSdy7dATC6QmEL81FIUuymZ0Wy9vH1jHkvpY57OiMeKGqib_Ow/viewform) if you have any feedback or suggestions. +### Download a free PDF + + If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.
+

https://packt.link/free-ebook/9781789612905

\ No newline at end of file From 25809ae666fb967b82f70ed6e4879dae2215a6d0 Mon Sep 17 00:00:00 2001 From: Packt-ITService <62882280+Packt-ITService@users.noreply.github.com> Date: Wed, 14 Dec 2022 13:44:42 +0530 Subject: [PATCH 17/18] add free ebook notification --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 1a95bc8..caccfde 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ + +### Get this product for $5 + +Packt is having its biggest sale of the year. Get this eBook or any other book, video, or course that you like just for $5 each + + +

[Buy now](https://packt.link/9781789612905)

+ + +

[Buy similar titles for just $5](https://subscription.packtpub.com/search)

+ + # Mastering GUI Programming with Python Mastering GUI Programming with Python From e1810e5275aef1062f361f2457ec1dd5138ca29d Mon Sep 17 00:00:00 2001 From: Packt-ITService <62882280+Packt-ITService@users.noreply.github.com> Date: Wed, 18 Jan 2023 15:22:23 +0530 Subject: [PATCH 18/18] remove 5$ campaign - 2022 --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index caccfde..02d948b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,4 @@ -### Get this product for $5 - -Packt is having its biggest sale of the year. Get this eBook or any other book, video, or course that you like just for $5 each - - -

[Buy now](https://packt.link/9781789612905)

- - -

[Buy similar titles for just $5](https://subscription.packtpub.com/search)

# Mastering GUI Programming with Python