[PyQt] Fwd: Mixin classes and PyQt4
Bryan A. Jones
bjones at ece.msstate.edu
Mon Feb 17 15:36:53 GMT 2014
"I don't anticipate there being many more PyQt4 releases"
-- famous last words... :)
Bryan
On Mon, Feb 17, 2014 at 2:52 AM, Phil Thompson
<phil at riverbankcomputing.com>wrote:
> On 16-02-2014 10:56 pm, Baz Walter wrote:
>
>> On 16/02/14 13:27, Phil Thompson wrote:
>>
>>> On 13-02-2014 6:54 pm, Martin Teichmann wrote:
>>>
>>>> Hi Baz, Hi Phil, Hi List,
>>>>
>>>> This actually only relates to multiple-inheritance. It should never
>>>>> be problem for true mixin classes.
>>>>>
>>>>
>>>> There youre certainly right. Its calling super() where I have my
>>>> issues. Your examples did not call super(), so the MRO doesnt
>>>> matter.
>>>>
>>>>
>>>> The one genuine issue with mixins in PyQt, is that you cannot
>>>>> inherit custom signals.
>>>>>
>>>>
>>>> Then it might be interesting for you that with my patch applied, it
>>>> does work. For example:
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------------------------
>>>> from PyQt4.QtGui import QWidget, QLabel, QApplication
>>>> from PyQt4.QtCore import pyqtSignal, QObject
>>>>
>>>> class A(QObject):
>>>> a = pyqtSignal(str)
>>>>
>>>> class B(A, QLabel):
>>>> b = pyqtSignal(str)
>>>>
>>>> class Printer(QObject):
>>>> def print(self, a):
>>>> print(a)
>>>>
>>>> app = QApplication([])
>>>>
>>>> b = B()
>>>> p = Printer()
>>>> b.a.connect(p.print)
>>>> b.b.connect(p.print)
>>>> b.a.emit(a)
>>>> b.b.emit(b)
>>>> b.setText(foo)
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>> correctly works with my patch applied. It does not if you let A
>>>> inherit from object.
>>>>
>>>
>>> At the moment (having just started to think about it again) I'm against
>>> your original patch as it is too different to the C++ behaviour.
>>>
>>> However I do like your other patch which raised an exception when
>>> inheriting from more than one C++ class.
>>>
>>
>> On the face of it, this seems like an entirely good thing to do.
>>
>> However, I suppose it's only fair to point out that this will
>> probably break code for at least some people, if this blog post is
>> anything to go by:
>>
>> http://trevorius.com/scrapbook/python/pyqt-multiple-inheritance/
>>
>> Of course, you could say that they got what they deserved for trying
>> to do something in PyQt that just wouldn't be allowed in Qt itself.
>> But whatever the rights and wrongs, there are going to be a few people
>> who might hope that this patch is only applied if the issue with
>> custom signals can be resolved first.
>>
>
> That rules it out for PyQt4 - I don't anticipate there being many more
> PyQt4 releases and I'm not going to introduce potential breakages at this
> stage.
>
> Phil
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
--
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298
Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140217/51d4acf0/attachment.html>
More information about the PyQt
mailing list