[PyQt] Fwd: Mixin classes and PyQt4

Baz Walter bazwal at ftml.net
Mon Feb 10 18:16:22 GMT 2014


On 10/02/14 09:55, Martin Teichmann wrote:
> I tried to write a mixin class for PyQt4 and, well, failed.
> Here is the short version of what I did:
>
> ========================
> from PyQt4.QtGui import QWidget, QApplication, QLabel
>
> class A(QWidget):
>      def sizeHint(self):
>          print('mixed in!', self.parent())
>          return super().sizeHint()
>
> class B(A, QLabel):
>      pass
>
> class C(QLabel, A):
>      pass
> ========================
>

Why not simply:

class A(object):
     def sizeHint(self):
         print('mixed in!', self.parent())
         return super().sizeHint()

class B(A, QLabel):
     pass

class C(A, QLabel):
     pass

-- 
Regards
Baz Walter


More information about the PyQt mailing list