@@ -680,6 +680,8 @@ def _icon(self, name):
680680
681681 def _init_toolbar (self ):
682682 self .basedir = str (cbook ._get_data_path ('images' ))
683+ # Ensure that zoom and pan are mutually exclusive.
684+ self ._button_group = QtWidgets .QButtonGroup ()
683685
684686 for text , tooltip_text , image_file , callback in self .toolitems :
685687 if text is None :
@@ -690,6 +692,7 @@ def _init_toolbar(self):
690692 self ._actions [callback ] = a
691693 if callback in ['zoom' , 'pan' ]:
692694 a .setCheckable (True )
695+ self ._button_group .addButton (self .widgetForAction (a ))
693696 if tooltip_text is not None :
694697 a .setToolTip (tooltip_text )
695698 if text == 'Subplots' :
@@ -763,18 +766,13 @@ def edit_parameters(self):
763766 ax = axes [titles .index (item )]
764767 figureoptions .figure_edit (ax , self )
765768
766- def _update_buttons_checked (self ):
767- # sync button checkstates to match active mode
768- self ._actions ['pan' ].setChecked (self ._active == 'PAN' )
769- self ._actions ['zoom' ].setChecked (self ._active == 'ZOOM' )
770-
771769 def pan (self , * args ):
772770 super ().pan (* args )
773- self ._update_buttons_checked ( )
771+ self ._actions [ 'pan' ]. setChecked ( self . _active == 'PAN' )
774772
775773 def zoom (self , * args ):
776774 super ().zoom (* args )
777- self ._update_buttons_checked ( )
775+ self ._actions [ 'zoom' ]. setChecked ( self . _active == 'ZOOM' )
778776
779777 def set_message (self , s ):
780778 self .message .emit (s )
0 commit comments