@@ -231,6 +231,7 @@ class NavigationToolbar2QT( NavigationToolbar2, qt.QWidget ):
231231
232232 def __init__ ( self , parent , canvas ):
233233 self .canvas = canvas
234+ self .buttons = {}
234235 qt .QWidget .__init__ ( self , parent )
235236
236237 # Layout toolbar buttons horizontally.
@@ -254,6 +255,8 @@ def _init_toolbar( self ):
254255 button = qt .QPushButton ( qt .QIconSet ( image ), "" , self )
255256 qt .QToolTip .add ( button , tooltip_text )
256257
258+ self .buttons [ text ] = button
259+
257260 # The automatic layout doesn't look that good - it's too close
258261 # to the images so add a margin around it.
259262 margin = 4
@@ -263,13 +266,24 @@ def _init_toolbar( self ):
263266 getattr ( self , callback ) )
264267 self .layout .addWidget ( button )
265268
269+ self .buttons [ 'Pan' ].setToggleButton ( True )
270+ self .buttons [ 'Zoom' ].setToggleButton ( True )
271+
266272 # Add the x,y location widget at the right side of the toolbar
267273 # The stretch factor is 1 which means any resizing of the toolbar
268274 # will resize this label instead of the buttons.
269275 self .locLabel = qt .QLabel ( "" , self )
270276 self .locLabel .setAlignment ( qt .Qt .AlignRight | qt .Qt .AlignVCenter )
271277 self .layout .addWidget ( self .locLabel , 1 )
272278
279+ def pan ( self , * args ):
280+ self .buttons [ 'Zoom' ].setOn ( False )
281+ NavigationToolbar2 .pan ( self , * args )
282+
283+ def zoom ( self , * args ):
284+ self .buttons [ 'Pan' ].setOn ( False )
285+ NavigationToolbar2 .zoom ( self , * args )
286+
273287 def dynamic_update ( self ):
274288 self .canvas .draw ()
275289
@@ -297,6 +311,12 @@ def save_figure( self ):
297311 if fname :
298312 self .canvas .print_figure ( fname .latin1 () )
299313
314+ def set_history_buttons ( self ):
315+ canBackward = ( self ._views ._pos > 0 )
316+ canForward = ( self ._views ._pos < len ( self ._views ._elements ) - 1 )
317+ self .buttons [ 'Back' ].setEnabled ( canBackward )
318+ self .buttons [ 'Forward' ].setEnabled ( canForward )
319+
300320# set icon used when windows are minimized
301321try :
302322 qt .window_set_default_icon_from_file (
0 commit comments