Repository: pyqtgraph/pyqtgraph

Issue:
Synchronize multiple pg.ImageView objects
Hello,

I encountered some difficulties two synchronize two (or more) pg.ImageView objects:

```python
import numpy as np
import pyqtgraph as pg


pg.mkQApp()
imv1 = pg.ImageView()
imv1.show()
imv1.setImage(np.random.random((100,8,8)))

imv2 = pg.ImageView()
imv2.show()
imv2.setImage(np.random.random((100,8,8)))

imv2.sigTimeChanged.connect(imv1.setCurrentIndex)
imv1.sigTimeChanged.connect(imv2.setCurrentIndex)
```

Both image views are synchronized when I set the position of the time axis via the mouse. However if I use keys, e.g. <space> for <play>, only the selected pg.ImageView is reacting. I found a small workaround, but I wonder, if this is the intended usage?

```python
import numpy as np
import pyqtgraph as pg

class PatchedImageView(pg.ImageView):
    def jumpFrames(self, n):
        super().jumpFrames(n)
        _, time = self.timeIndex(self.timeLine)
        self.sigTimeChanged.emit(self.currentIndex, time)


pg.mkQApp()
imv1 = PatchedImageView()
imv1.show()
imv1.setImage(np.random.random((100,8,8)))

imv2 = PatchedImageView()
imv2.show()
imv2.setImage(np.random.random((100,8,8)))

imv2.sigTimeChanged.connect(imv1.setCurrentIndex)
imv1.sigTimeChanged.connect(imv2.setCurrentIndex)
```




Discussion:

Resolving patch:
diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py
--- a/pyqtgraph/imageview/ImageView.py
+++ b/pyqtgraph/imageview/ImageView.py
@@ -131,7 +131,7 @@ def __init__(self, parent=None, name="ImageView", view=None, imageItem=None,
         self.scene = self.ui.graphicsView.scene()
         self.ui.histogram.setLevelMode(levelMode)
         
-        self.ignoreTimeLine = False
+        self.ignorePlaying = False
         
         if view is None:
             self.view = ViewBox()
@@ -498,11 +498,11 @@ def timeout(self):
         
     def setCurrentIndex(self, ind):
         """Set the currently displayed frame index."""
-        self.currentIndex = np.clip(ind, 0, self.getProcessedImage().shape[self.axes['t']]-1)
-        self.updateImage()
-        self.ignoreTimeLine = True
-        self.timeLine.setValue(self.tVals[self.currentIndex])
-        self.ignoreTimeLine = False
+        index = np.clip(ind, 0, self.getProcessedImage().shape[self.axes['t']]-1)
+        self.ignorePlaying = True
+        # Implicitly call timeLineChanged
+        self.timeLine.setValue(self.tVals[index])
+        self.ignorePlaying = False
 
     def jumpFrames(self, n):
         """Move video frame ahead n frames (may be negative)"""
@@ -696,16 +696,13 @@ def normalize(self, image):
         return norm
         
     def timeLineChanged(self):
-        #(ind, time) = self.timeIndex(self.ui.timeSlider)
-        if self.ignoreTimeLine:
-            return
-        self.play(0)
+        if not self.ignorePlaying:
+            self.play(0)
+
         (ind, time) = self.timeIndex(self.timeLine)
         if ind != self.currentIndex:
             self.currentIndex = ind
             self.updateImage()
-        #self.timeLine.setPos(time)
-        #self.emit(QtCore.SIGNAL('timeChanged'), ind, time)
         self.sigTimeChanged.emit(ind, time)
 
     def updateImage(self, autoHistogramRange=True):


Test patch: