Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Thanks for the fix, it looks good to me. Could you add a comment in the code, since I don't think it's super obvious what |
How about this: 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. When the user defines a small figure size(e.g. 2x2),+ # this will cause:+ # 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) |
Basically yes. A bit clearer
|
Did we also want to shrink the toolbar height, as noted in#28330 (comment)? |
I'd be in favor of that. |
sandyowlet commentedMay 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Sorry, I used to think this display issue was simply due to the height of the toolbar. When the scaling is set to 150% on windows, canvas is resized to 300 * 300, but the toolbar is resized to 300 * 50. This makes the appearance on Windows as expected, but not on Linux. I'm not very clear on how rescaling works with TkAgg. Does anyone have experience with this? |
I'm not an expert on this, but the relevant starting point in our code base is here:
|
PR summary
Closes#28330 .
Before: Left After: Right
PR checklist