Show More
@@ -47,6 +47,9 b' we proposed the following informal protocol:' | |||||
47 | to see if ``_in_event_loop`` attribute has been set. If it is set, you |
|
47 | to see if ``_in_event_loop`` attribute has been set. If it is set, you | |
48 | *must* use its value. If it has not been set, you can query the toolkit |
|
48 | *must* use its value. If it has not been set, you can query the toolkit | |
49 | in the normal manner. |
|
49 | in the normal manner. | |
|
50 | * If you want GUI support and no one else has created an application or | |||
|
51 | started the event loop you *must* do this. We don't want projects to | |||
|
52 | attempt to defer these things to someone else if they themselves need it. | |||
50 |
|
53 | |||
51 | The functions below implement this logic for each GUI toolkit. If you need |
|
54 | The functions below implement this logic for each GUI toolkit. If you need | |
52 | to create custom application subclasses, you will likely have to modify this |
|
55 | to create custom application subclasses, you will likely have to modify this |
@@ -302,13 +302,15 b' class QtKernel(Kernel):' | |||||
302 | """Start a kernel with QtPy4 event loop integration.""" |
|
302 | """Start a kernel with QtPy4 event loop integration.""" | |
303 |
|
303 | |||
304 | from PyQt4 import QtGui, QtCore |
|
304 | from PyQt4 import QtGui, QtCore | |
305 | self.app = QtGui.QApplication([]) |
|
305 | from IPython.lib.guisupport import ( | |
306 | self.app.setQuitOnLastWindowClosed (False) |
|
306 | get_app_qt4, start_event_loop_qt4 | |
|
307 | ) | |||
|
308 | self.app = get_app_qt4([" "]) | |||
|
309 | self.app.setQuitOnLastWindowClosed(False) | |||
307 | self.timer = QtCore.QTimer() |
|
310 | self.timer = QtCore.QTimer() | |
308 | self.timer.timeout.connect(self.do_one_iteration) |
|
311 | self.timer.timeout.connect(self.do_one_iteration) | |
309 | self.timer.start(50) |
|
312 | self.timer.start(50) | |
310 | self.app.exec_() |
|
313 | start_event_loop_qt4(self.app) | |
311 |
|
||||
312 |
|
314 | |||
313 | class WxKernel(Kernel): |
|
315 | class WxKernel(Kernel): | |
314 | """A Kernel subclass with Wx support.""" |
|
316 | """A Kernel subclass with Wx support.""" | |
@@ -317,6 +319,7 b' class WxKernel(Kernel):' | |||||
317 | """Start a kernel with wx event loop support.""" |
|
319 | """Start a kernel with wx event loop support.""" | |
318 |
|
320 | |||
319 | import wx |
|
321 | import wx | |
|
322 | from IPython.lib.guisupport import start_event_loop_wx | |||
320 | doi = self.do_one_iteration |
|
323 | doi = self.do_one_iteration | |
321 |
|
324 | |||
322 | # We have to put the wx.Timer in a wx.Frame for it to fire properly. |
|
325 | # We have to put the wx.Timer in a wx.Frame for it to fire properly. | |
@@ -342,7 +345,7 b' class WxKernel(Kernel):' | |||||
342 | # The redirect=False here makes sure that wx doesn't replace |
|
345 | # The redirect=False here makes sure that wx doesn't replace | |
343 | # sys.stdout/stderr with its own classes. |
|
346 | # sys.stdout/stderr with its own classes. | |
344 | self.app = IPWxApp(redirect=False) |
|
347 | self.app = IPWxApp(redirect=False) | |
345 | self.app.MainLoop() |
|
348 | start_event_loop_wx(self.app) | |
346 |
|
349 | |||
347 |
|
350 | |||
348 | class TkKernel(Kernel): |
|
351 | class TkKernel(Kernel): |
General Comments 0
You need to be logged in to leave comments.
Login now