How to keep the scale of the items while resizing a window

24 views
Skip to first unread message

yunsong zhao

unread,
Mar 7, 2020, 6:37:45 AM3/7/20
to pyqtgraph

Hi, there, 
All the examples provided by pyqtgraph, changes the scale of the items in a viewbox when resizing the parent window, ie, the view range retains.
But I want to keep the scale while resizing the window.
How to implement this. Thanks!

Patrick

unread,
Mar 8, 2020, 12:38:14 AM3/8/20
to pyqtgraph
Hi,

I don't think there's an easy "switch" to turn on the behaviour you describe. I think you could do it by connecting to the sigResized signal of the ViewBox, and calculating new values for the visible region and then calling setRange(). There would be a bit of work remembering old values of the ViewBox size, and maybe ignoring the event on initialisation or if your setRange() call also triggers the sigResized signal again.
With a little more work (querying the window position) then you might be able to differentiate between a resize from the top-left or bottom-right corners.

There may be an easier way to do it, but that's the only way I can think of at the moment.

Patrick
Reply all
Reply to author
Forward
0 new messages