我在2个单独的文件中写了2个单独的类。名为atcore_py.pyx的文件1具有AndorCameraSDK
,文件2具有python类AndorCameraGUI
。
在下面找到每个片段的片段。
File 1:
cdef class AndorCameraSDK(object):
def __cinit__(self, master):
print('SDK Init') # Show that AndorCameraSDK.__init__ runs
self.master = master # Save reference to master
def LiveAcquisition(self):
print('SDK LiveAcquisition') # Show that AndorCameraSDK.LiveAcquisition runs
pBuf = 'Some data' # Dummy data
self.master.LivePlot(pBuf ) # Call instance of AndorCameraGUI.LivePlot
file 2:
import AndorCameraSDK as andorcamera
class AndorCameraGUI(andorcamera):
def __init__(self):
print('GUI Init') # Show that AndorCameraGUI.__init__ runs
def LiveImageGUI(self):
print('GUI LiveImageGUI') # Show that AndorCameraGUI.LiveImageGUI runs
self.camera = andorcamera(self) # Create instance of AndorCameraSDK
self.camera.LiveAcquisition() # Call AndorCameraSDK.LiveAcquisition
def LivePlot(self):
print('GUI LivePlot') # Show that AndorCameraGUI.LivePlot runs
app = AndorCameraGUI()
app.LiveImageGUI()
我可以在AndorCameraSDK
的{{1}}内调用函数。但反过来不起作用。它返回说self.master = master不是AndorCameraGUI
中的属性。
谁能告诉我怎么能解决这个问题。