Skip to content

Commit

Permalink
'Confirm kernel restart' updated on tab change
Browse files Browse the repository at this point in the history
The way I originally wrote the code, it was possible for the
"Kernel" -> "Confirm kernel restart" checkbox to get out of sync with
the currently active tab. It turns out that QTabWidget has a
'currentChanged' slot that can be leveraged to update the checkbox to
properly reflect the currently active tab widget.
  • Loading branch information
ivanov committed Jun 15, 2012
1 parent dada3fa commit a41db72
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions IPython/frontend/qt/console/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Fernando Perez
* Bussonnier Matthias
* Thomas Kluyver
* Paul Ivanov
"""

Expand Down Expand Up @@ -77,6 +78,7 @@ def __init__(self, app,
self.tab_widget.setDocumentMode(True)
self.tab_widget.setTabsClosable(True)
self.tab_widget.tabCloseRequested[int].connect(self.close_tab)
self.tab_widget.currentChanged.connect(self.update_restart_checkbox)

self.setCentralWidget(self.tab_widget)
# hide tab bar at first, since we have no tabs:
Expand Down Expand Up @@ -844,12 +846,11 @@ def interrupt_kernel_active_frontend(self):
def toggle_confirm_restart_active_frontend(self):
widget = self.active_frontend
widget.confirm_restart = not widget.confirm_restart
# XXX: whenever tabs are switched, the checkbox may not be
# representative of the state of the active widget. The next line
# ensures that at least after toggling, the checkbox represents the
# state this widget is in.
self.confirm_restart_kernel_action.setChecked(widget.confirm_restart)

def update_restart_checkbox(self):
widget = self.active_frontend
self.confirm_restart_kernel_action.setChecked(widget.confirm_restart)

def cut_active_frontend(self):
widget = self.active_frontend
Expand Down

0 comments on commit a41db72

Please sign in to comment.