Hi,

Yeah, you won't be able to do that as ImageView is a widget and not a 
GraphicsItem. You could copy the ImageView code and modify it to do what 
you want, but might be overkill. If you just want the histogram and 
gradient editor, then something like this would do it:

from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import numpy as np

app = QtGui.QApplication([])
view = pg.GraphicsView()
l = pg.GraphicsLayout(border=(100,100,100))
view.setCentralItem(l)
view.show()
view.setWindowTitle('pyqtgraph example: GraphicsLayout')
view.resize(800,600)

p1 = l.addPlot(title="Plot 1")
p2 = l.addPlot(title="Plot 2")
vb = l.addViewBox(lockAspect=True)
img = pg.ImageItem(np.random.normal(size=(100,100)))
vb.addItem(img)
cbar = pg.HistogramLUTItem(image=img)
cbar.gradient.loadPreset('thermal')
l.addItem(cbar)

app.exec_()


If you wanted the timeline/slider too, then you'd need to replicate it as 
well, which wouldn't be too hard. Look inside the ImageView code and 
copy/paste a bit.

Patrick

On Thursday, 13 September 2018 19:33:36 UTC+9:30, Gregory Bättig wrote:
>
>
> I have a QT application where I use the GraphicsView in combination with 
> GraphicsLayout. I took the example "GraphicsLayout.py" from the PyQtGraph 
> repository as a starting point. The below code snippet shows from where I 
> started out.
>
> app = QtGui.QApplication([])
> view = pg.GraphicsView()
> l = pg.GraphicsLayout(border=(100,100,100))
> view.setCentralItem(l)
> view.show()
> view.setWindowTitle('pyqtgraph example: GraphicsLayout')
> view.resize(800,600)
>
> p1 = l.addPlot(title="Plot 1")
> p2 = l.addPlot(title="Plot 2")
> vb = l.addViewBox(lockAspect=True)
> img = pg.ImageItem(np.random.normal(size=(100,100)))
> vb.addItem(img)
>
> This approach works fine but I now would like to add an ImageView instead 
> of an ImageItem to the layout. Mainly because I want to take advantage of 
> the histogram and slider functionalities already inbuilt in ImageView 
> objects. 
>
> In the example "DataSlicing" they add ImageView objects to a layout, but 
> there it is a QtGui.QtGridLayout object and the ImageViews are added as 
> widgets and not as items. 
>
> cw = QtGui.QWidget()
> win.setCentralWidget(cw)
> l = QtGui.QGridLayout()
> cw.setLayout(l)
> imv1 = pg.ImageView()
> imv2 = pg.ImageView()
> l.addWidget(imv1, 0, 0)
> l.addWidget(imv2, 1, 0)
>
> Is there a way to combine these two approaches, by adding ImageView 
> objects to a pg.GraphicsLayout, or is that not the right way to go?
>
> Thanks for any kind of advice
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/cf902971-9fba-4cc8-a994-ecbd78d52274%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to