Reputation: 271
All I am trying to do is inherit from two different classes.
from traits.api import HasTraits
from PyQt4 import QtCore, QtGui, uic
class Main_Excel_Class(HasTraits,QtGui.QMainWindow):
pass
I had the "metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases"
error initially. But I resolved it by putting in a __metaclass__ attribute:
from traits.api import HasTraits
from PyQt4 import QtCore, QtGui, uic
class Main_Excel_Class_Meta(type(HasTraits), type(QtGui.QMainWindow)):
pass
class Main_Excel_Class(HasTraits,QtGui.QMainWindow):
__metaclass__ = Main_Excel_Class_Meta
But now I end up getting the
"TypeError: Error when calling the metaclass bases
multiple bases have instance lay-out conflict"
error. I tried looking into other similar questions but i honestly did not understand much.Any insights as to how to approach to solve this problem would be very much appreciated. Thankyou
Upvotes: 3
Views: 3811
Reputation: 271
I finally resolved it with a little research. Apparently the error had to do something with the __slots__ attribute's conflicts which is used when allocating heap memory for the new type.Here are the changes I made :
from traits.api import HasTraits
from PyQt4 import QtCore, QtGui, uic
class Main_Excel_Class_Meta(type(HasTraits), type(QtGui.QMainWindow)):
pass
class HasTraits(QtGui.QMainWindow):
pass
class Main_Excel_Class(HasTraits):
__metaclass__ = Main_Excel_Class_Meta
For a better understanding of the working I had suggest you check this post
http://mcjeff.blogspot.in/2009/05/odd-python-errors.html
Upvotes: 8