diff --git a/IPython/qt/client.py b/IPython/qt/client.py index 45f9832..b29e691 100644 --- a/IPython/qt/client.py +++ b/IPython/qt/client.py @@ -72,16 +72,6 @@ class QtZMQSocketChannel(SuperQObject): message_received = QtCore.Signal(object) - #--------------------------------------------------------------------------- - # InProcessChannel interface - #--------------------------------------------------------------------------- - - def call_handlers_later(self, *args, **kwds): - """ Call the message handlers later. - """ - do_later = lambda: self.call_handlers(*args, **kwds) - QtCore.QTimer.singleShot(0, do_later) - def process_events(self): """ Process any pending GUI events. """ diff --git a/IPython/qt/inprocess.py b/IPython/qt/inprocess.py index 0cabe83..4db0f65 100644 --- a/IPython/qt/inprocess.py +++ b/IPython/qt/inprocess.py @@ -9,13 +9,53 @@ from IPython.kernel.inprocess import ( from IPython.kernel.inprocess.channels import InProcessChannel from IPython.utils.traitlets import Type -from .kernel_mixins import ( ChannelQObject, - QtKernelClientMixin, - QtKernelManagerMixin, +from .util import SuperQObject +from .kernel_mixins import ( + QtKernelClientMixin, QtKernelManagerMixin, ) -class QtInProcessChannel(ChannelQObject, InProcessChannel): - pass +class QtInProcessChannel(SuperQObject, InProcessChannel): + # Emitted when the channel is started. + started = QtCore.Signal() + + # Emitted when the channel is stopped. + stopped = QtCore.Signal() + + # Emitted when any message is received. + message_received = QtCore.Signal(object) + + def start(self): + """ Reimplemented to emit signal. + """ + super(QtInProcessChannel, self).start() + self.started.emit() + + def stop(self): + """ Reimplemented to emit signal. + """ + super(QtInProcessChannel, self).stop() + self.stopped.emit() + + def call_handlers_later(self, *args, **kwds): + """ Call the message handlers later. + """ + do_later = lambda: self.call_handlers(*args, **kwds) + QtCore.QTimer.singleShot(0, do_later) + + def call_handlers(self, msg): + self.message_received.emit(msg) + + def process_events(self): + """ Process any pending GUI events. + """ + QtCore.QCoreApplication.instance().processEvents() + + def flush(self, timeout=1.0): + """ Reimplemented to ensure that signals are dispatched immediately. + """ + super(QtInProcessChannel, self).flush() + self.process_events() + class QtInProcessKernelClient(QtKernelClientMixin, InProcessKernelClient): """ An in-process KernelManager with signals and slots. diff --git a/IPython/qt/kernel_mixins.py b/IPython/qt/kernel_mixins.py index b7963f3..9a63806 100644 --- a/IPython/qt/kernel_mixins.py +++ b/IPython/qt/kernel_mixins.py @@ -9,50 +9,6 @@ from IPython.utils.traitlets import HasTraits, Type from .util import MetaQObjectHasTraits, SuperQObject -class ChannelQObject(SuperQObject): - - # Emitted when the channel is started. - started = QtCore.Signal() - - # Emitted when the channel is stopped. - stopped = QtCore.Signal() - - # Emitted when any message is received. - message_received = QtCore.Signal(object) - - def start(self): - """ Reimplemented to emit signal. - """ - super(ChannelQObject, self).start() - self.started.emit() - - def stop(self): - """ Reimplemented to emit signal. - """ - super(ChannelQObject, self).stop() - self.stopped.emit() - - def call_handlers_later(self, *args, **kwds): - """ Call the message handlers later. - """ - do_later = lambda: self.call_handlers(*args, **kwds) - QtCore.QTimer.singleShot(0, do_later) - - def call_handlers(self, msg): - self.message_received.emit(msg) - - def process_events(self): - """ Process any pending GUI events. - """ - QtCore.QCoreApplication.instance().processEvents() - - def flush(self): - """ Reimplemented to ensure that signals are dispatched immediately. - """ - super(ChannelQObject, self).flush() - self.process_events() - - class QtKernelRestarterMixin(MetaQObjectHasTraits('NewBase', (HasTraits, SuperQObject), {})): _timer = None