@@ -845,6 +845,16 @@ def _onPaint(self, evt):
845845 self .gui_repaint (drawDC = drawDC )
846846 drawDC .Destroy ()
847847
848+ def _make_growable (self ):
849+ # for a standalone window, the canvas is created non-growable in the
850+ # beginning to preserve the figure size
851+ # now modify the sizer item properties to allow growth
852+ sz = self .GetParent ().GetSizer ()
853+ si = sz .GetItem (self )
854+ si .SetProportion (1 )
855+ si .SetFlag (si .GetFlag () | wx .EXPAND )
856+ #si.SetMinSize((2, 2))
857+
848858 def _onSize (self , evt ):
849859 """
850860 Called when wxEventSize is generated.
@@ -1183,7 +1193,8 @@ def __init__(self, num, fig):
11831193 self .canvas .SetInitialSize (wx .Size (fig .bbox .width , fig .bbox .height ))
11841194 self .canvas .SetFocus ()
11851195 self .sizer = wx .BoxSizer (wx .VERTICAL )
1186- self .sizer .Add (self .canvas , 1 , wx .TOP | wx .LEFT | wx .EXPAND )
1196+ # initially, add non-growable; later call _make_growable
1197+ self .sizer .Add (self .canvas , 0 , wx .TOP | wx .LEFT )
11871198 # By adding toolbar in sizer, we are able to put it at the bottom
11881199 # of the frame - so appearance is closer to GTK version
11891200
@@ -1205,8 +1216,7 @@ def __init__(self, num, fig):
12051216 self .sizer .Add (self .toolbar , 0 , wx .LEFT | wx .EXPAND )
12061217 self .SetSizer (self .sizer )
12071218 self .Fit ()
1208-
1209- self .canvas .SetMinSize ((2 , 2 ))
1219+ wx .CallLater (0 , self .canvas ._make_growable )
12101220
12111221 # give the window a matplotlib icon rather than the stock one.
12121222 # This is not currently working on Linux and is untested elsewhere.
0 commit comments