mouseClickEvent is in ViewBoxCustom.py and is correctly triggered when you click the scene. compute_spc_map is in SPCanalyse.py and ViewBoxCustom.py doesn't import it as that would make a cyclic import. I know it can be done, but I want to avoid it.
snippet from ViewBoxCustom
from SPCanalyse import MainWindow #This import should not exist
def mouseClickEvent(self, ev):
elif ev.button() == QtCore.Qt.LeftButton:
ev.accept()
# The following line does not work because MainWindow is **NOT** imported
MainWindow.compute_spc_map(ev.pos().x(), ev.pos().y())
snippet from SPCanalyse. SPCanalyse imports ViewBoxCustom so as to access functions and generate app functionality
from ViewBoxCustom import MultiRoiViewBox # MultiRoiViewBox contains mouseClickEvent
def compute_spc_map(self, x, y):
if not self.preprocessed_frames == None:
self.image = fj.get_correlation_map(y, x, self.preprocessed_frames)
I cant just place compute_spc_map in ViewBoxCustom because preprocessed_frames is a variable generated and used in SPCanalyse
I thought it might work to connect the mouseClickEvent in ViewBoxCustom with compute_spc_map in SPCanalyse doing the following in SPCanalyse
from ViewBoxCustom import MultiRoiViewBox
self.vb = MultiRoiViewBox(lockAspect=True,enableMenu=True)
self.vb.mouseClickEvent.connect(self.compute_spc_map)
sadly mouseClickEvent has no attribute 'connect'