I am using Python 3 with PyQt4 and :
I have a first class :
class MainWindow(QtGui.QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.initUI()
with this function in it :
def Fn_GetSpnBitsValue(self):
print (self.SpnBits.value())
self.BitNumber =self.SpnBits.value()
print(self.BitNumber)
return self.BitNumber
as you can see I return the value of one of my spinners created in this class Now I want to access this variable "self.BitNumber" from another class. In other language I would very simply write myValue = MainWindow.self.BitNumber but it seems it wont be as easy in python, so I have look at class inheritance so my second class inherit of my first one...
I would be very tempted to write like this ... :
class BitsWindow(QtGui.QWidget, MainWindow):
def __init__(self):
super(BitsWindow, self).__init__()
self.initUI2()
Which makes perfect sens to me, I tell my second class "look you inherit from this class so everything she know, you know it as well" but I then get this message error :
class BitsWindow(QtGui.QWidget, MainWindow):
TypeError: Cannot create a consistent method resolution
order (MRO) for bases QWidget, MainWindow
Which don't really make any sens to me actually. By looking further on the web I have think understand the key is in that bit :
def __init__(self):
super(BitsWindow, self).__init__()
self.initUI2()
But I really struggle understanding the concept, I am not sure what this is doing despite numerous tutorials and forum answers. (Maybe, probably, didn't find the good ones.)
Any help would be much appreciated;
Many Thanks !