Skip to content

fix: Fix unstable tkagg small plot size. #29989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,14 @@ def __init__(self, canvas, window=None, *, pack_toolbar=True):
window = canvas.get_tk_widget().master
tk.Frame.__init__(self, master=window, borderwidth=2,
width=int(canvas.figure.bbox.width), height=50)
# Avoid message_label expanding the toolbar size, and in turn expanding the
# canvas size.
# Without pack_propagate(False), when the user defines a small figure size
# (e.g. 2x2):
# 1. Figure size that is bigger than the user's expectation.
# 2. When message_label is refreshed by mouse enter/leave, the canvas
# size will also be changed.
self.pack_propagate(False)

self._buttons = {}
for text, tooltip_text, image_file, callback in self.toolitems:
Expand Down
Loading