I'm trying to make a gui with pyqt5. The code works fine when I don't have the varaibales under __slots__
but once I put them in I get an error saying
"(built-in function connectSlotsByName) returned a result with an error set"
and on the top of the error it says
"'MainWindow' object has no attribute 'z'"
Below is part of my code(which is sort of long). I'm not even sure if the __slots__
is a problem. Because it worked fine when I had from 'fName' to 'has_data', but as soon as I added things under 'x', it started to give me that error.
class MainWindow(QDialog):
__slots__ = (
# find_file_Callback
'fName',
'cubefilename',
'ROI',
'ROIcount',
'has_data',
'x',
'x_end',
'y',
'y_end',
'z',
'ptflag',
'rgflag',
'rgflagROI',
'intens'
)
def __init__(self):
super(MainWindow,self).__init__()
loadUi("ptype1.ui",self)
self.find_file.clicked.connect(self.find_file_Callback)
self.micrometer.setChecked(True)
self.start_cube.clicked.connect(self.start_cube_Callback)
self.fName = ""
self.cubefilename = ""
self.ROI = 0
self.ROIcount = 0
self.has_data = 0
self.x = 0
self.x_end = 0
self.y = 0
self.y_end = 0
self.z = 0
self.ptflag = False
self.rgflag = False
self.rgflagROI = False
self.intens = 0
def start_cube_Callback(self):
self.cubefilename = self.fName[0]
filename = self.cubefilename
print("Working to read datacube")
fileID = open (filename)
data = np.fromfile(fileID, dtype = np.float32)
x=int(data[0])
y=int(data[1])
z=int(data[2])
end = len(data)
imgZ = data[end-z:end]
img = data[3:x*y*z +3]
del data
img = img.reshape(z,x,y, order = 'F')
img = img.transpose(2, 1, 0)
img = np.flip(img,0)
imgX = np.arange(37.5, 75*x+37.5, 75)
imgY = np.arange(75, 150*y+75, 150)
fileID.close()
print("Working to display data\n")
scalefact = 1e3
self.x = abs((imgX-imgX[0])/scalefact)
xm, xn = 1, len(imgX)
if xm > xn:
self.x = self.x.conj().T
self.x_end = self.x[len(self.x) - 1]
self.y = abs((imgY-imgY[0])/scalefact)
ym, yn = 1, len(imgY)
if ym < yn:
self.y = self.y.conj().T
self.y_end = self.y[len(self.y) - 1]
self.z = imgZ