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

Skip to content

Commit ea3f98b

Browse files
committed
GTK4: Fix forward application of set_size_inches
1 parent 7c6d9eb commit ea3f98b

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
@@ -374,17 +374,10 @@ def set_window_title(self, title):
374374
def resize(self, width, height):
375375
"""Set the canvas size in pixels."""
376376
if self.toolbar:
377-
toolbar_size = self.toolbar.size_request()
378-
height += toolbar_size.height
377+
min_size, nat_size = self.toolbar.get_preferred_size()
378+
height += nat_size.height
379379
canvas_size = self.canvas.get_allocation()
380-
if canvas_size.width == canvas_size.height == 1:
381-
# A canvas size of (1, 1) cannot exist in most cases, because
382-
# window decorations would prevent such a small window. This call
383-
# must be before the window has been mapped and widgets have been
384-
# sized, so just change the window's starting size.
385-
self.window.set_default_size(width, height)
386-
else:
387-
self.window.resize(width, height)
380+
self.window.set_default_size(width, height)
388381

389382

390383
class NavigationToolbar2GTK4(_NavigationToolbar2GTK, Gtk.Box):

0 commit comments

Comments
 (0)