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

Skip to content

Commit ef74de4

Browse files
committed
GTK4: Fix forward application of set_size_inches
1 parent a6e01b5 commit ef74de4

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/matplotlib/backends/backend_gtk4.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,17 +373,10 @@ def set_window_title(self, title):
373373
def resize(self, width, height):
374374
"""Set the canvas size in pixels."""
375375
if self.toolbar:
376-
toolbar_size = self.toolbar.size_request()
377-
height += toolbar_size.height
376+
min_size, nat_size = self.toolbar.get_preferred_size()
377+
height += nat_size.height
378378
canvas_size = self.canvas.get_allocation()
379-
if canvas_size.width == canvas_size.height == 1:
380-
# A canvas size of (1, 1) cannot exist in most cases, because
381-
# window decorations would prevent such a small window. This call
382-
# must be before the window has been mapped and widgets have been
383-
# sized, so just change the window's starting size.
384-
self.window.set_default_size(width, height)
385-
else:
386-
self.window.resize(width, height)
379+
self.window.set_default_size(width, height)
387380

388381

389382
class NavigationToolbar2GTK4(_NavigationToolbar2GTK, Gtk.Box):

0 commit comments

Comments
 (0)