@@ -678,6 +678,17 @@ def __init__(self, parent, id, figure):
678678 h = int (math .ceil (h ))
679679
680680 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+
681692 # Create the drawing bitmap
682693 self .bitmap = wx .EmptyBitmap (w , h )
683694 DEBUG_MSG ("__init__() - bitmap w:%d h:%d" % (w ,h ), 2 , self )
@@ -1234,15 +1245,7 @@ def __init__(self, num, fig):
12341245 statbar = StatusBarWx (self )
12351246 self .SetStatusBar (statbar )
12361247 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 ))
12461249 self .sizer = wx .BoxSizer (wx .VERTICAL )
12471250 self .sizer .Add (self .canvas , 1 , wx .TOP | wx .LEFT | wx .EXPAND )
12481251 # By adding toolbar in sizer, we are able to put it at the bottom
@@ -1363,7 +1366,7 @@ def set_window_title(self, title):
13631366
13641367 def resize (self , width , height ):
13651368 'Set the canvas size in pixels'
1366- self .canvas .SetSizeFunc (wx .Size (width , height ))
1369+ self .canvas .SetInitialSize (wx .Size (width , height ))
13671370 self .window .GetSizer ().Fit (self .window )
13681371
13691372# Identifiers for toolbar controls - images_wx contains bitmaps for the images
0 commit comments