Fix tiny wx plot window on wxPython 4.3 - #32158
Conversation
`FigureFrameWx.__init__` called `canvas.SetInitialSize(w, h)` (which sets both the size and the min size to (w, h)), then immediately reset the min size to (2, 2), and only then called `self.Fit()`. With wxPython 4.3 (wxWidgets 3.3) `Fit` sizes the frame from the canvas's current min size, so the (2, 2) reset collapsed the window to a tiny size that had to be manually resized; wxPython 4.2.5 was unaffected. Call `Fit()` while the canvas min size is still the initial (w, h), then relax it to (2, 2) so the user can still resize the window smaller. The reporter confirmed this resolves the tiny-window behaviour on wxPython 4.3. Fixes matplotlib#32143
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
Heads up on the one red check: I don't think a regression test is feasible here: the bug only manifests on wxPython 4.3 (wxWidgets 3.3) with a real display. On the wx 4.2.x available in CI, both the old and new ordering produce a correctly-sized window, so a test would pass regardless of the fix and wouldn't actually guard the regression. The verification is the issue reporter confirming the reorder resolves the tiny-window behaviour on wx 4.3 (#32143). Happy to adjust if you'd prefer a different approach. |
QuLogic
left a comment
There was a problem hiding this comment.
Can't test, but seems reasonable if the original reporter confirmed it worked.
…158-on-v3.11.x Backport PR #32158 on branch v3.11.x (Fix tiny wx plot window on wxPython 4.3)
PR summary
Fixes #32143 — with wxPython 4.3 / 4.3.1 the WxAgg plot window opens tiny (~132×131) and must be manually resized; wxPython 4.2.5 is unaffected.
Cause
In
FigureFrameWx.__init__(lib/matplotlib/backends/backend_wx.py):SetInitialSize(w, h)sets both the size and the min size to(w, h), but the next line resets the canvas min size to(2, 2), and only then isFit()called. wxPython 4.3 tracks wxWidgets 3.3, whereFit()sizes the frame from the canvas's current min size — so the(2, 2)reset collapses the window. wxPython 4.2.5 (wxWidgets 3.2) honoured the initial size instead.Fix
Call
Fit()while the canvas min size is still the initial(w, h), then relax it to(2, 2)afterwards so the window can still be resized smaller.Testing
This is GUI-backend window sizing, which isn't covered by the automated suite. The issue reporter tested this exact reorder and confirmed it:
— #32143 (comment) (and their confirmation).