@@ -129,6 +129,7 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
129129 keyvald = { QtCore .Qt .Key_Control : 'control' ,
130130 QtCore .Qt .Key_Shift : 'shift' ,
131131 QtCore .Qt .Key_Alt : 'alt' ,
132+ QtCore .Qt .Key_Return : 'enter'
132133 }
133134 # left 1, middle 2, right 3
134135 buttond = {1 :1 , 2 :3 , 4 :2 }
@@ -314,16 +315,19 @@ def __init__( self, canvas, num ):
314315 self .window ._destroying = False
315316
316317 self .toolbar = self ._get_toolbar (self .canvas , self .window )
317- self .window .addToolBar (self .toolbar )
318- QtCore .QObject .connect (self .toolbar , QtCore .SIGNAL ("message" ),
319- self .window .statusBar ().showMessage )
318+ if self .toolbar is not None :
319+ self .window .addToolBar (self .toolbar )
320+ QtCore .QObject .connect (self .toolbar , QtCore .SIGNAL ("message" ),
321+ self .window .statusBar ().showMessage )
322+ tbs_height = self .toolbar .sizeHint ().height ()
323+ else :
324+ tbs_height = 0
320325
321326 # resize the main window so it will display the canvas with the
322327 # requested size:
323328 cs = canvas .sizeHint ()
324- tbs = self .toolbar .sizeHint ()
325329 sbs = self .window .statusBar ().sizeHint ()
326- self .window .resize (cs .width (), cs .height ()+ tbs . height () + sbs .height ())
330+ self .window .resize (cs .width (), cs .height ()+ tbs_height + sbs .height ())
327331
328332 self .window .setCentralWidget (self .canvas )
329333
@@ -335,7 +339,8 @@ def __init__( self, canvas, num ):
335339
336340 def notify_axes_change ( fig ):
337341 # This will be called whenever the current axes is changed
338- if self .toolbar != None : self .toolbar .update ()
342+ if self .toolbar is not None :
343+ self .toolbar .update ()
339344 self .canvas .figure .add_axobserver ( notify_axes_change )
340345
341346 def _widgetclosed ( self ):
0 commit comments