Skip to content

Commit b70c5f2

Browse files
committed
Use self.close rather than self.destroy for quit action
Fixes a problem where window hangs on quit. Closes #12.
1 parent 565b8e3 commit b70c5f2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Chapter03/calendar_app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def __init__(self):
2727
self.layout().addWidget(self.submit_btn)
2828
self.cancel_btn = qtw.QPushButton(
2929
'Cancel',
30-
clicked=self.destroy
30+
# Errata: The book contains this line:
31+
#clicked=self.destroy
32+
# It should call self.close instead, like so:
33+
clicked=self.close
3134
)
3235
self.layout().addWidget(self.cancel_btn)
3336
self.show()

Chapter04/text_editor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ def __init__(self):
9494
file_menu.addSeparator()
9595

9696
# add an action with a callback
97-
quit_action = file_menu.addAction('Quit', self.destroy)
97+
# Errata: The book contains this line:
98+
#quit_action = file_menu.addAction('Quit', self.destroy)
99+
# It should call self.close instead, like so:
100+
quit_action = file_menu.addAction('Quit', self.close)
98101

99102
# connect to a Qt Slot
100103
edit_menu.addAction('Undo', self.textedit.undo)

0 commit comments

Comments
 (0)