Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8c051b

Browse files
committed
Calculate initial GTK window size using logical DPI
Otherwise, if the pixel ratio is changed before the window is created, the window will be scaled up an extra time. This occurs on GTK3, but not GTK4, due to some different order of events, but I changed the GTK4 backend to do the same for consistency.
1 parent 145a713 commit f8c051b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ def __init__(self, canvas, num):
341341

342342
self.vbox.pack_start(self.canvas, True, True, 0)
343343
# calculate size for window
344-
w = int(self.canvas.figure.bbox.width)
345-
h = int(self.canvas.figure.bbox.height)
344+
w, h = self.canvas.get_width_height()
346345

347346
self.toolbar = self._get_toolbar()
348347

lib/matplotlib/backends/backend_gtk4.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ def __init__(self, canvas, num):
288288

289289
self.vbox.prepend(self.canvas)
290290
# calculate size for window
291-
w = int(self.canvas.figure.bbox.width)
292-
h = int(self.canvas.figure.bbox.height)
291+
w, h = self.canvas.get_width_height()
293292

294293
self.toolbar = self._get_toolbar()
295294

0 commit comments

Comments
 (0)