Skip to content

Commit ff8ef13

Browse files
committed
Fix problem in print dialog
Fix problem where opening the print dialog immediately starts printing. (Thanks DevinLand). Closes #8
1 parent fe728b6 commit ff8ef13

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Chapter11/invoice_maker_printable.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,14 @@ def _print_document(self):
259259
self.preview.document().print(self.printer)
260260

261261
def print_dialog(self):
262-
self._print_document()
262+
# Errata: the book contained this line:
263+
#self._print_document()
264+
# As noted by DevinLand in issue #8, this can cause the document to start printing.
263265
dialog = qtps.QPrintDialog(self.printer, self)
266+
267+
# Instead we'll add this line, so _print_document is triggered when the dialog is
268+
# accepted:
269+
dialog.accepted.connect(self._print_document)
264270
dialog.exec()
265271
self._update_preview_size()
266272

0 commit comments

Comments
 (0)