Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da078ca

Browse filesBrowse files
committed
gtk: Correctly resize canvas to intended size.
Previously, it was the window that was resized to the intended size, thus making the canvas smaller by the toolbar height. Fixes #10083 for GTK3. Fixes #10566 for GTK3.
1 parent 8feb6d8 commit da078ca
Copy full SHA for da078ca

File tree

Expand file treeCollapse file tree

1 file changed

+15
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-4
lines changed

‎lib/matplotlib/backends/backend_gtk3.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_gtk3.py
+15-4Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

445456
class NavigationToolbar2GTK3(NavigationToolbar2, Gtk.Toolbar):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.