how can i add a scrollbar to GraphicsLayoutWidget

1,564 views
Skip to first unread message

fwt11

unread,
Jul 2, 2013, 7:04:32 AM7/2/13
to pyqt...@googlegroups.com
hi,
I need to add a lot of plots to a GraphicsLayoutWidget. But only the top several plots displays. Can i add a scollbar to the GraphicsLayoutWidget, then i can see all the plots.
how can I.
thanks!

Luke Campagnola

unread,
Jul 2, 2013, 7:49:03 AM7/2/13
to pyqt...@googlegroups.com
You can embed any widget inside a QScrollArea: https://qt-project.org/doc/qt-4.8/qscrollarea.html
For example:

import pyqtgraph as pg                                                                                                                                        
app = pg.mkQApp()                                                                                                                                
sa = pg.QtGui.QScrollArea()                                                                                                                                
w = pg.GraphicsLayoutWidget()                                                                                                                      
w.setFixedHeight(2000)
sa.setWidget(w)
for i in range(20):
  w.addPlot(row=i, col=0)
sa.show()

 
Luke

Bastian Neumann

unread,
Sep 5, 2013, 8:52:03 AM9/5/13
to pyqt...@googlegroups.com
Thank you for this hint. I was looking for the same thing. But now I have the Scrollbar but the GraphicsLayoutWidget does not occupy the whole area in the Window. Is there a way to set minimum Sizes to the Items in the GraphcalLayoutWidget?

Luke Campagnola

unread,
Sep 7, 2013, 12:14:52 AM9/7/13
to pyqt...@googlegroups.com
On Thu, Sep 5, 2013 at 8:52 AM, Bastian Neumann <neumann...@gmail.com> wrote:
Thank you for this hint. I was looking for the same thing. But now I have the Scrollbar but the GraphicsLayoutWidget does not occupy the whole area in the Window. Is there a way to set minimum Sizes to the Items in the GraphcalLayoutWidget?

The QScrollArea documentation discusses this a little:  http://qt-project.org/doc/qt-4.8/qscrollarea.html
The first thing I would try is call setFixedHeight / setFixedWidth on the GraphicsLayoutWidget.

Luke

Reply all
Reply to author
Forward
0 new messages