@@ -436,10 +436,21 @@ def set_window_title(self, title):
436436
437437 def resize (self , width , height ):
438438 """Set the canvas size in pixels."""
439- #_, _, cw, ch = self.canvas.allocation
440- #_, _, ww, wh = self.window.allocation
441- #self.window.resize (width-cw+ww, height-ch+wh)
442- self .window .resize (width , height )
439+ if self .toolbar :
440+ toolbar_size = self .toolbar .size_request ()
441+ height += toolbar_size .height
442+ if self .statusbar :
443+ statusbar_size = self .statusbar .size_request ()
444+ height += statusbar_size .height
445+ canvas_size = self .canvas .get_allocation ()
446+ if canvas_size .width == canvas_size .height == 1 :
447+ # A canvas size of (1, 1) cannot exist in most cases, because
448+ # window decorations would prevent such a small window. This call
449+ # must be before the window has been mapped and widgets have been
450+ # sized, so just change the window's starting size.
451+ self .window .set_default_size (width , height )
452+ else :
453+ self .window .resize (width , height )
443454
444455
445456class NavigationToolbar2GTK3 (NavigationToolbar2 , Gtk .Toolbar ):
0 commit comments