Skip to content

Commit 9d596dd

Browse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR matplotlib#32158: Fix tiny wx plot window on wxPython 4.3
1 parent c2fa099 commit 9d596dd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/matplotlib/backends/backend_wx.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,16 @@ def __init__(self, num, fig, *, canvas_class):
935935
# otherwise the toolbar further resizes the canvas.
936936
w, h = map(math.ceil, fig.bbox.size)
937937
self.canvas.SetInitialSize(self.FromDIP(wx.Size(w, h)))
938-
self.canvas.SetMinSize(self.FromDIP(wx.Size(2, 2)))
939938
self.canvas.SetFocus()
940939

940+
# Size the frame to the canvas's initial size *before* relaxing the
941+
# canvas min size. ``SetInitialSize`` sets both the size and the min
942+
# size to (w, h); with wxPython 4.3 (wxWidgets 3.3) ``Fit`` uses the
943+
# current min size, so shrinking it to (2, 2) first collapses the
944+
# window to a tiny size (GH #32143). Relax the min size afterwards so
945+
# the user can still resize the window smaller.
941946
self.Fit()
947+
self.canvas.SetMinSize(self.FromDIP(wx.Size(2, 2)))
942948

943949
self.Bind(wx.EVT_CLOSE, self._on_close)
944950

0 commit comments

Comments
 (0)