Show More
@@ -10,7 +10,13 b' from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \\' | |||||
10 | XReqSocketChannel, RepSocketChannel |
|
10 | XReqSocketChannel, RepSocketChannel | |
11 | from util import MetaQObjectHasTraits |
|
11 | from util import MetaQObjectHasTraits | |
12 |
|
12 | |||
13 |
|
13 | # When doing multiple inheritance from QtCore.QObject and other classes | ||
|
14 | # the calling of the parent __init__'s is a subtle issue: | |||
|
15 | # * QtCore.QObject does not call super so you can't use super and put | |||
|
16 | # QObject first in the inheritance list. | |||
|
17 | # * QtCore.QObject.__init__ takes 1 argument, the parent. So if you are going | |||
|
18 | # to use super, any class that comes before QObject must pass it something | |||
|
19 | # reasonable. | |||
14 |
|
20 | |||
15 | class QtSubSocketChannel(SubSocketChannel, QtCore.QObject): |
|
21 | class QtSubSocketChannel(SubSocketChannel, QtCore.QObject): | |
16 |
|
22 | |||
@@ -106,7 +112,6 b' class QtRepSocketChannel(RepSocketChannel, QtCore.QObject):' | |||||
106 | QtCore.QObject.__init__(self) |
|
112 | QtCore.QObject.__init__(self) | |
107 | RepSocketChannel.__init__(self, *args, **kw) |
|
113 | RepSocketChannel.__init__(self, *args, **kw) | |
108 |
|
114 | |||
109 |
|
||||
110 | class QtKernelManager(KernelManager, QtCore.QObject): |
|
115 | class QtKernelManager(KernelManager, QtCore.QObject): | |
111 | """ A KernelManager that provides signals and slots. |
|
116 | """ A KernelManager that provides signals and slots. | |
112 | """ |
|
117 | """ | |
@@ -124,6 +129,10 b' class QtKernelManager(KernelManager, QtCore.QObject):' | |||||
124 | xreq_channel_class = QtXReqSocketChannel |
|
129 | xreq_channel_class = QtXReqSocketChannel | |
125 | rep_channel_class = QtRepSocketChannel |
|
130 | rep_channel_class = QtRepSocketChannel | |
126 |
|
131 | |||
|
132 | def __init__(self, *args, **kw): | |||
|
133 | QtCore.QObject.__init__(self) | |||
|
134 | KernelManager.__init__(self, *args, **kw) | |||
|
135 | ||||
127 | #--------------------------------------------------------------------------- |
|
136 | #--------------------------------------------------------------------------- | |
128 | # 'KernelManager' interface |
|
137 | # 'KernelManager' interface | |
129 | #--------------------------------------------------------------------------- |
|
138 | #--------------------------------------------------------------------------- |
@@ -11,6 +11,7 b' from IPython.utils.traitlets import HasTraits' | |||||
11 | MetaHasTraits = type(HasTraits) |
|
11 | MetaHasTraits = type(HasTraits) | |
12 | MetaQObject = type(QtCore.QObject) |
|
12 | MetaQObject = type(QtCore.QObject) | |
13 |
|
13 | |||
|
14 | # You can switch the order of the parents here. | |||
14 | class MetaQObjectHasTraits(MetaQObject, MetaHasTraits): |
|
15 | class MetaQObjectHasTraits(MetaQObject, MetaHasTraits): | |
15 | """ A metaclass that inherits from the metaclasses of both HasTraits and |
|
16 | """ A metaclass that inherits from the metaclasses of both HasTraits and | |
16 | QObject. |
|
17 | QObject. | |
@@ -18,8 +19,9 b' class MetaQObjectHasTraits(MetaQObject, MetaHasTraits):' | |||||
18 | Using this metaclass allows a class to inherit from both HasTraits and |
|
19 | Using this metaclass allows a class to inherit from both HasTraits and | |
19 | QObject. See QtKernelManager for an example. |
|
20 | QObject. See QtKernelManager for an example. | |
20 | """ |
|
21 | """ | |
21 |
|
22 | # pass | ||
22 | def __init__(cls, name, bases, dct): |
|
23 | # ???You can get rid of this, but only if the order above is MetaQObject, MetaHasTraits | |
23 |
|
|
24 | # def __init__(cls, name, bases, dct): | |
24 |
Meta |
|
25 | # MetaQObject.__init__(cls, name, bases, dct) | |
|
26 | # MetaHasTraits.__init__(cls, name, bases, dct) | |||
25 |
|
27 |
@@ -385,6 +385,7 b' class KernelManager(HasTraits):' | |||||
385 | self._rep_address = (LOCALHOST, 0) if rep_address is None else rep_address |
|
385 | self._rep_address = (LOCALHOST, 0) if rep_address is None else rep_address | |
386 | self.context = zmq.Context() if context is None else context |
|
386 | self.context = zmq.Context() if context is None else context | |
387 | self.session = Session() if session is None else session |
|
387 | self.session = Session() if session is None else session | |
|
388 | super(KernelManager, self).__init__() | |||
388 |
|
389 | |||
389 | #-------------------------------------------------------------------------- |
|
390 | #--------------------------------- ----------------------------------------- | |
390 | # Channel management methods: |
|
391 | # Channel management methods: |
General Comments 0
You need to be logged in to leave comments.
Login now