Show More
@@ -21,10 +21,17 Authors: | |||||
21 | # stdlib imports |
|
21 | # stdlib imports | |
22 | import sys |
|
22 | import sys | |
23 | import webbrowser |
|
23 | import webbrowser | |
|
24 | from threading import Thread | |||
24 |
|
25 | |||
25 | # System library imports |
|
26 | # System library imports | |
26 | from IPython.external.qt import QtGui,QtCore |
|
27 | from IPython.external.qt import QtGui,QtCore | |
27 |
|
28 | |||
|
29 | def background(f): | |||
|
30 | """call a function in a simple thread, to prevent blocking""" | |||
|
31 | t = Thread(target=f) | |||
|
32 | t.start() | |||
|
33 | return t | |||
|
34 | ||||
28 | #----------------------------------------------------------------------------- |
|
35 | #----------------------------------------------------------------------------- | |
29 | # Classes |
|
36 | # Classes | |
30 | #----------------------------------------------------------------------------- |
|
37 | #----------------------------------------------------------------------------- | |
@@ -185,14 +192,17 class MainWindow(QtGui.QMainWindow): | |||||
185 | reply = box.exec_() |
|
192 | reply = box.exec_() | |
186 | if reply == 1: # close All |
|
193 | if reply == 1: # close All | |
187 | for slave in slave_tabs: |
|
194 | for slave in slave_tabs: | |
|
195 | background(slave.kernel_manager.stop_channels) | |||
188 | self.tab_widget.removeTab(self.tab_widget.indexOf(slave)) |
|
196 | self.tab_widget.removeTab(self.tab_widget.indexOf(slave)) | |
189 | closing_widget.execute("exit") |
|
197 | closing_widget.execute("exit") | |
190 | self.tab_widget.removeTab(current_tab) |
|
198 | self.tab_widget.removeTab(current_tab) | |
|
199 | background(kernel_manager.stop_channels) | |||
191 | elif reply == 0: # close Console |
|
200 | elif reply == 0: # close Console | |
192 | if not closing_widget._existing: |
|
201 | if not closing_widget._existing: | |
193 | # Have kernel: don't quit, just close the tab |
|
202 | # Have kernel: don't quit, just close the tab | |
194 | closing_widget.execute("exit True") |
|
203 | closing_widget.execute("exit True") | |
195 | self.tab_widget.removeTab(current_tab) |
|
204 | self.tab_widget.removeTab(current_tab) | |
|
205 | background(kernel_manager.stop_channels) | |||
196 | else: |
|
206 | else: | |
197 | reply = QtGui.QMessageBox.question(self, title, |
|
207 | reply = QtGui.QMessageBox.question(self, title, | |
198 | "Are you sure you want to close this Console?"+ |
|
208 | "Are you sure you want to close this Console?"+ | |
@@ -204,15 +214,15 class MainWindow(QtGui.QMainWindow): | |||||
204 | self.tab_widget.removeTab(current_tab) |
|
214 | self.tab_widget.removeTab(current_tab) | |
205 | elif keepkernel: #close console but leave kernel running (no prompt) |
|
215 | elif keepkernel: #close console but leave kernel running (no prompt) | |
206 | self.tab_widget.removeTab(current_tab) |
|
216 | self.tab_widget.removeTab(current_tab) | |
207 |
|
|
217 | background(kernel_manager.stop_channels) | |
208 | kernel_manager.stop_channels() |
|
|||
209 | else: #close console and kernel (no prompt) |
|
218 | else: #close console and kernel (no prompt) | |
210 | self.tab_widget.removeTab(current_tab) |
|
219 | self.tab_widget.removeTab(current_tab) | |
211 | if kernel_manager and kernel_manager.channels_running: |
|
220 | if kernel_manager and kernel_manager.channels_running: | |
212 | kernel_manager.shutdown_kernel() |
|
|||
213 | for slave in slave_tabs: |
|
221 | for slave in slave_tabs: | |
214 |
slave.kernel_manager.stop_channels |
|
222 | background(slave.kernel_manager.stop_channels) | |
215 | self.tab_widget.removeTab(self.tab_widget.indexOf(slave)) |
|
223 | self.tab_widget.removeTab(self.tab_widget.indexOf(slave)) | |
|
224 | kernel_manager.shutdown_kernel() | |||
|
225 | background(kernel_manager.stop_channels) | |||
216 |
|
226 | |||
217 | self.update_tab_bar_visibility() |
|
227 | self.update_tab_bar_visibility() | |
218 |
|
228 |
General Comments 0
You need to be logged in to leave comments.
Login now