kernel_mixins.py
50 lines
| 1.6 KiB
| text/x-python
|
PythonLexer
MinRK
|
r16567 | """Defines a KernelManager that provides signals and slots.""" | ||
# Copyright (c) IPython Development Team. | ||||
# Distributed under the terms of the Modified BSD License. | ||||
epatters
|
r8408 | |||
from IPython.external.qt import QtCore | ||||
epatters
|
r8456 | from IPython.utils.traitlets import HasTraits, Type | ||
Thomas Kluyver
|
r13347 | from .util import MetaQObjectHasTraits, SuperQObject | ||
epatters
|
r8408 | |||
Thomas Kluyver
|
r13359 | class QtKernelRestarterMixin(MetaQObjectHasTraits('NewBase', (HasTraits, SuperQObject), {})): | ||
MinRK
|
r10308 | |||
_timer = None | ||||
Thomas Kluyver
|
r13359 | class QtKernelManagerMixin(MetaQObjectHasTraits('NewBase', (HasTraits, SuperQObject), {})): | ||
MinRK
|
r10308 | """ A KernelClient that provides signals and slots. | ||
""" | ||||
kernel_restarted = QtCore.Signal() | ||||
Thomas Kluyver
|
r13359 | class QtKernelClientMixin(MetaQObjectHasTraits('NewBase', (HasTraits, SuperQObject), {})): | ||
MinRK
|
r10288 | """ A KernelClient that provides signals and slots. | ||
epatters
|
r8408 | """ | ||
MinRK
|
r10288 | # Emitted when the kernel client has started listening. | ||
epatters
|
r8408 | started_channels = QtCore.Signal() | ||
MinRK
|
r10288 | # Emitted when the kernel client has stopped listening. | ||
epatters
|
r8408 | stopped_channels = QtCore.Signal() | ||
#--------------------------------------------------------------------------- | ||||
MinRK
|
r10288 | # 'KernelClient' interface | ||
epatters
|
r8408 | #--------------------------------------------------------------------------- | ||
#------ Channel management ------------------------------------------------- | ||||
def start_channels(self, *args, **kw): | ||||
""" Reimplemented to emit signal. | ||||
""" | ||||
MinRK
|
r10288 | super(QtKernelClientMixin, self).start_channels(*args, **kw) | ||
epatters
|
r8408 | self.started_channels.emit() | ||
def stop_channels(self): | ||||
""" Reimplemented to emit signal. | ||||
""" | ||||
MinRK
|
r10288 | super(QtKernelClientMixin, self).stop_channels() | ||
epatters
|
r8408 | self.stopped_channels.emit() | ||