Show More
@@ -72,16 +72,6 b' class QtZMQSocketChannel(SuperQObject):' | |||
|
72 | 72 | |
|
73 | 73 | message_received = QtCore.Signal(object) |
|
74 | 74 | |
|
75 | #--------------------------------------------------------------------------- | |
|
76 | # InProcessChannel interface | |
|
77 | #--------------------------------------------------------------------------- | |
|
78 | ||
|
79 | def call_handlers_later(self, *args, **kwds): | |
|
80 | """ Call the message handlers later. | |
|
81 | """ | |
|
82 | do_later = lambda: self.call_handlers(*args, **kwds) | |
|
83 | QtCore.QTimer.singleShot(0, do_later) | |
|
84 | ||
|
85 | 75 | def process_events(self): |
|
86 | 76 | """ Process any pending GUI events. |
|
87 | 77 | """ |
@@ -9,13 +9,53 b' from IPython.kernel.inprocess import (' | |||
|
9 | 9 | from IPython.kernel.inprocess.channels import InProcessChannel |
|
10 | 10 | |
|
11 | 11 | from IPython.utils.traitlets import Type |
|
12 |
from . |
|
|
13 | QtKernelClientMixin, | |
|
14 | QtKernelManagerMixin, | |
|
12 | from .util import SuperQObject | |
|
13 | from .kernel_mixins import ( | |
|
14 | QtKernelClientMixin, QtKernelManagerMixin, | |
|
15 | 15 | ) |
|
16 | 16 | |
|
17 |
class QtInProcessChannel( |
|
|
18 | pass | |
|
17 | class QtInProcessChannel(SuperQObject, InProcessChannel): | |
|
18 | # Emitted when the channel is started. | |
|
19 | started = QtCore.Signal() | |
|
20 | ||
|
21 | # Emitted when the channel is stopped. | |
|
22 | stopped = QtCore.Signal() | |
|
23 | ||
|
24 | # Emitted when any message is received. | |
|
25 | message_received = QtCore.Signal(object) | |
|
26 | ||
|
27 | def start(self): | |
|
28 | """ Reimplemented to emit signal. | |
|
29 | """ | |
|
30 | super(QtInProcessChannel, self).start() | |
|
31 | self.started.emit() | |
|
32 | ||
|
33 | def stop(self): | |
|
34 | """ Reimplemented to emit signal. | |
|
35 | """ | |
|
36 | super(QtInProcessChannel, self).stop() | |
|
37 | self.stopped.emit() | |
|
38 | ||
|
39 | def call_handlers_later(self, *args, **kwds): | |
|
40 | """ Call the message handlers later. | |
|
41 | """ | |
|
42 | do_later = lambda: self.call_handlers(*args, **kwds) | |
|
43 | QtCore.QTimer.singleShot(0, do_later) | |
|
44 | ||
|
45 | def call_handlers(self, msg): | |
|
46 | self.message_received.emit(msg) | |
|
47 | ||
|
48 | def process_events(self): | |
|
49 | """ Process any pending GUI events. | |
|
50 | """ | |
|
51 | QtCore.QCoreApplication.instance().processEvents() | |
|
52 | ||
|
53 | def flush(self, timeout=1.0): | |
|
54 | """ Reimplemented to ensure that signals are dispatched immediately. | |
|
55 | """ | |
|
56 | super(QtInProcessChannel, self).flush() | |
|
57 | self.process_events() | |
|
58 | ||
|
19 | 59 | |
|
20 | 60 | class QtInProcessKernelClient(QtKernelClientMixin, InProcessKernelClient): |
|
21 | 61 | """ An in-process KernelManager with signals and slots. |
@@ -9,50 +9,6 b' from IPython.utils.traitlets import HasTraits, Type' | |||
|
9 | 9 | from .util import MetaQObjectHasTraits, SuperQObject |
|
10 | 10 | |
|
11 | 11 | |
|
12 | class ChannelQObject(SuperQObject): | |
|
13 | ||
|
14 | # Emitted when the channel is started. | |
|
15 | started = QtCore.Signal() | |
|
16 | ||
|
17 | # Emitted when the channel is stopped. | |
|
18 | stopped = QtCore.Signal() | |
|
19 | ||
|
20 | # Emitted when any message is received. | |
|
21 | message_received = QtCore.Signal(object) | |
|
22 | ||
|
23 | def start(self): | |
|
24 | """ Reimplemented to emit signal. | |
|
25 | """ | |
|
26 | super(ChannelQObject, self).start() | |
|
27 | self.started.emit() | |
|
28 | ||
|
29 | def stop(self): | |
|
30 | """ Reimplemented to emit signal. | |
|
31 | """ | |
|
32 | super(ChannelQObject, self).stop() | |
|
33 | self.stopped.emit() | |
|
34 | ||
|
35 | def call_handlers_later(self, *args, **kwds): | |
|
36 | """ Call the message handlers later. | |
|
37 | """ | |
|
38 | do_later = lambda: self.call_handlers(*args, **kwds) | |
|
39 | QtCore.QTimer.singleShot(0, do_later) | |
|
40 | ||
|
41 | def call_handlers(self, msg): | |
|
42 | self.message_received.emit(msg) | |
|
43 | ||
|
44 | def process_events(self): | |
|
45 | """ Process any pending GUI events. | |
|
46 | """ | |
|
47 | QtCore.QCoreApplication.instance().processEvents() | |
|
48 | ||
|
49 | def flush(self): | |
|
50 | """ Reimplemented to ensure that signals are dispatched immediately. | |
|
51 | """ | |
|
52 | super(ChannelQObject, self).flush() | |
|
53 | self.process_events() | |
|
54 | ||
|
55 | ||
|
56 | 12 | class QtKernelRestarterMixin(MetaQObjectHasTraits('NewBase', (HasTraits, SuperQObject), {})): |
|
57 | 13 | |
|
58 | 14 | _timer = None |
General Comments 0
You need to be logged in to leave comments.
Login now