@@ -680,6 +680,8 @@ def _icon(self, name):
680
680
681
681
def _init_toolbar (self ):
682
682
self .basedir = str (cbook ._get_data_path ('images' ))
683
+ # Ensure that zoom and pan are mutually exclusive.
684
+ self ._button_group = QtWidgets .QButtonGroup ()
683
685
684
686
for text , tooltip_text , image_file , callback in self .toolitems :
685
687
if text is None :
@@ -690,6 +692,7 @@ def _init_toolbar(self):
690
692
self ._actions [callback ] = a
691
693
if callback in ['zoom' , 'pan' ]:
692
694
a .setCheckable (True )
695
+ self ._button_group .addButton (self .widgetForAction (a ))
693
696
if tooltip_text is not None :
694
697
a .setToolTip (tooltip_text )
695
698
if text == 'Subplots' :
@@ -763,18 +766,13 @@ def edit_parameters(self):
763
766
ax = axes [titles .index (item )]
764
767
figureoptions .figure_edit (ax , self )
765
768
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
-
771
769
def pan (self , * args ):
772
770
super ().pan (* args )
773
- self ._update_buttons_checked ( )
771
+ self ._actions [ 'pan' ]. setChecked ( self . _active == 'PAN' )
774
772
775
773
def zoom (self , * args ):
776
774
super ().zoom (* args )
777
- self ._update_buttons_checked ( )
775
+ self ._actions [ 'zoom' ]. setChecked ( self . _active == 'ZOOM' )
778
776
779
777
def set_message (self , s ):
780
778
self .message .emit (s )
0 commit comments