[PyQt] Two base classed inherit QWidget
simozack
simozack at yahoo.it
Mon Feb 2 16:17:23 GMT 2009
2009/2/2, Matt Smith <melkor at orangepalantir.org>:
>
> > > Could someone explain to me, how is that possible and why it works:
> > >
> > > class A(QWidget):
> > > def __init__(self):
> > > QWidget.__init__(self)
> > >
> > > class B(QWidget):
> > > def __init__(self):
> > > QWidget.__init__(self)
> > >
> > > class C(A, B):
> > > def __init__(self):
> > > A.__init__(self)
> > > B.__init__(self)
> > >
> > > I mean, it's cool, that it works - I just used and I love it. But
> > > having just C(QWidget, QWidget) won't work. Why above example does?
> >
> > I think it works because A and B are two different and separated
> > instances of the same object (QWidget) while QWidget is the same
> > class.
> >
> > Try to substitute QWidget with the python standard 'object' class and
> > you have the same behaviour and this error:
> >
> > 'duplicate base class object'
> >
> > HTH,
> > Simone
>
> Have you tried this on a windows system? I had a program that worked
> fine in linux and then when I moved it to windows it failed to exit the
> program because I was initializing an object twice.
Yes, I tried this on Windows with python 2.6.
Simone
More information about the PyQt
mailing list