From 28b37c15148791ac90d3a466867f8f594f065362 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 30 Aug 2017 20:54:04 -0400 Subject: [PATCH] FIX: prevent the canvas from jump sizes due to DPI changes closes #8736 thanks to @rayosborn --- lib/matplotlib/backends/backend_qt5.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index a6cc3b686554..a61de4f31e06 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -509,8 +509,7 @@ def __init__(self, canvas, num): # requested size: cs = canvas.sizeHint() sbs = self.window.statusBar().sizeHint() - self._status_and_tool_height = tbs_height + sbs.height() - height = cs.height() + self._status_and_tool_height + height = cs.height() + tbs_height + sbs.height() self.window.resize(cs.width(), height) self.window.setCentralWidget(self.canvas) @@ -554,8 +553,11 @@ def _get_toolbar(self, canvas, parent): return toolbar def resize(self, width, height): - 'set the canvas size in pixels' - self.window.resize(width, height + self._status_and_tool_height) + # these are Qt methods so they return sizes in 'virtual' pixels + # so we do not need to worry about dpi scaling here. + extra_width = self.window.width() - self.canvas.width() + extra_height = self.window.height() - self.canvas.height() + self.window.resize(width+extra_width, height+extra_height) def show(self): self.window.show() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy