RemoteGraphicsView and QSplitter

206 views
Skip to first unread message

Gregor Beck

unread,
Jun 30, 2021, 6:33:09 AM6/30/21
to pyqtgraph
Hi

I have an application with 4 online plots handled by RemoteGraphicsView for performance reasons. Something like this:

import pyqtgraph as pg
import pyqtgraph.widgets.RemoteGraphicsView

app = pg.mkQApp()
layout = pg.LayoutWidget()

view = pg.widgets.RemoteGraphicsView.RemoteGraphicsView()
layout.addWidget(view)
win = view.pg.GraphicsLayout()
view.setCentralItem(win)

plt = [view.pg.PlotItem() for i in range(0,4)]
[win.addItem(p, col=0, row=i) for i,p in enumerate(plt)]

layout.show()

if __name__ == '__main__':
    app.exec()

I tried to make the individual plot sizes adjustable with help of QSplitter, which in the local case worked like this:

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

app = pg.mkQApp()
layout = pg.LayoutWidget()

splitter = QtGui.QSplitter()
splitter.setOrientation(QtCore.Qt.Orientation.Vertical)
layout.addWidget(splitter)

plt = [pg.PlotWidget() for i in range(0,4)]
[splitter.addWidget(p) for p in plt]

layout.show()

if __name__ == '__main__':
    app.exec()

however I wasn't able to get this working in the remote case. I tried local and remote versions of the splitter (view.pg.Qt.QtGui.QSplitter) but always got lost in the interactions of widgets, items and remote proxies.

Some ideas how to get this or something similar working?

Thanks for your help!

Gregor

Patrick

unread,
Jun 30, 2021, 11:13:01 PM6/30/21
to pyqtgraph
Hi,

I think the easiest is to actually create three QSplitters (either two horizontal inside one vertical, or vice-versa) so you have the four resizable panels, then add four separate pyqtgraph GraphicsView (or similar) instances into that splitter grid.

Boilerplate code generated from Qt Designer and pyside2-uic for demonstration:

self.horizontalLayout = QHBoxLayout(Form)
self.splitter_3 = QSplitter(Form)
self.splitter_3.setOrientation(Qt.Vertical)
self.splitter = QSplitter(self.splitter_3)
self.splitter.setOrientation(Qt.Horizontal)
self.graphicsView = GraphicsView(self.splitter)
self.splitter.addWidget(self.graphicsView)
self.graphicsView_2 = GraphicsView(self.splitter)
self.splitter.addWidget(self.graphicsView_2)
self.splitter_3.addWidget(self.splitter)
self.splitter_2 = QSplitter(self.splitter_3)
self.splitter_2.setOrientation(Qt.Horizontal)
self.graphicsView_3 = GraphicsView(self.splitter_2)
self.splitter_2.addWidget(self.graphicsView_3)
self.graphicsView_4 = GraphicsView(self.splitter_2)
self.splitter_2.addWidget(self.graphicsView_4)
self.splitter_3.addWidget(self.splitter_2)
self.horizontalLayout.addWidget(self.splitter_3)



Hope that helps!
Patrick

Gregor Beck

unread,
Jul 1, 2021, 1:19:01 AM7/1/21
to pyqt...@googlegroups.com

Hi,


thank you for your answer.


Am Donnerstag, 1. Juli 2021, 05:13:01 CEST schrieb Patrick:

> I think the easiest is to actually create three QSplitters ...

> then add four separate pyqtgraph GraphicsView ...

> Hope that helps!

No, unfortunately not.

This only resembles my second code snippet how it would work with local

GraphicViews.

I need to use a RemoteGraphicsView for performance reasons and I think I have

to use only one because the x-axes of the plots are linked together.

On the RemoteGraphicsView I only found methods to addItems but no way to

addWidgets.


May be I need a way to turn a QSplitter into an Item to do something like:

view.setCentralItem(splitter)


Gregor


--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/buXRTEefm-0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/b569fae4-75a6-4580-851d-97200c2a1f5bn%40googlegroups.com.

Patrick

unread,
Jul 1, 2021, 2:21:30 AM7/1/21
to pyqtgraph
Hi,

Ah yes, the issue with inter-process communications will be a problem when using multiple RemoteGraphicsView objects (for linking axes etc)...

First, I think you need to make sure you know the distinction between Qt and pyqtgraph "Widgets" versus Qt and pyqtgraph "GraphicsItems". See the diagram in the documentation here. A GraphicsView is a Widget, but then everything placed inside of the GraphicsView must be GraphicsItems. That is, you can't place a QSplitter Widget inside a GraphicsView and use it to arrange the other GraphicsItems.

What you want is possible of course, but there is no pre-built "splitter" type of GraphicItem that I know of, and so it would require coding one for yourself.
Perhaps first look at the pyqtgraph GraphicsLayout example to see how GraphicsItems can be arranged inside of a GraphicsLayout, and imagine that the very top and left labels (which are LabelItems) span the rows and columns like you'd want a splitter to do. Labels don't have any user interaction though, so starting with something that does, like an AxisItem or ButtonItem, might be a good idea. You'd then need to connect mouse drags to changes to the GraphicsLayout.layout (which is a QGraphicsGridLayout object). It sounds a little complicated, but I think it should work!

Patrick

Gregor Beck

unread,
Jul 2, 2021, 5:14:30 AM7/2/21
to pyqtgraph
Hi,

seems I have to dive a lot deeper into Qt and pyqtgraph than I had hoped.

What about extending  RemoteGraphicsView to provide more than one remote view so one could create several RemotePlotWidgets?

For now I added checkboxes to switch the Plots invisible which does part of the job.

Gregor
Reply all
Reply to author
Forward
0 new messages