@@ -678,6 +678,17 @@ def __init__(self, parent, id, figure):
678
678
h = int (math .ceil (h ))
679
679
680
680
wx .Panel .__init__ (self , parent , id , size = wx .Size (w , h ))
681
+
682
+ def do_nothing (* args , ** kwargs ):
683
+ warnings .warn ('could not find a setinitialsize function for backend_wx; please report your wxpython version=%s to the matplotlib developers list' % backend_version )
684
+ pass
685
+
686
+ # try to find the set size func across wx versions
687
+ try :
688
+ getattr (self , 'SetInitialSize' )
689
+ except AttributeError :
690
+ self .SetInitialSize = getattr (self , 'SetBestFittingSize' , do_nothing )
691
+
681
692
# Create the drawing bitmap
682
693
self .bitmap = wx .EmptyBitmap (w , h )
683
694
DEBUG_MSG ("__init__() - bitmap w:%d h:%d" % (w ,h ), 2 , self )
@@ -1234,15 +1245,7 @@ def __init__(self, num, fig):
1234
1245
statbar = StatusBarWx (self )
1235
1246
self .SetStatusBar (statbar )
1236
1247
self .canvas = self .get_canvas (fig )
1237
-
1238
- def do_nothing (* args , ** kwargs ):
1239
- warnings .warn ('could not find a SetSizeFunc for backend_wx; please report your wxpython version=%s to the matplotlib developers list' % backend_version )
1240
- pass
1241
-
1242
- # try to find the set size func across wx versions
1243
- self .SetSizeFunc = getattr (self .canvas , 'SetInitialSize' ,
1244
- getattr (self .canvas , 'SetBestFittingSize' , do_nothing ))
1245
- self .SetSizeFunc (wx .Size (fig .bbox .width , fig .bbox .height ))
1248
+ self .canvas .SetInitialSize (wx .Size (fig .bbox .width , fig .bbox .height ))
1246
1249
self .sizer = wx .BoxSizer (wx .VERTICAL )
1247
1250
self .sizer .Add (self .canvas , 1 , wx .TOP | wx .LEFT | wx .EXPAND )
1248
1251
# By adding toolbar in sizer, we are able to put it at the bottom
@@ -1363,7 +1366,7 @@ def set_window_title(self, title):
1363
1366
1364
1367
def resize (self , width , height ):
1365
1368
'Set the canvas size in pixels'
1366
- self .canvas .SetSizeFunc (wx .Size (width , height ))
1369
+ self .canvas .SetInitialSize (wx .Size (width , height ))
1367
1370
self .window .GetSizer ().Fit (self .window )
1368
1371
1369
1372
# Identifiers for toolbar controls - images_wx contains bitmaps for the images
0 commit comments