@@ -685,6 +685,8 @@ def _icon(self, name, color=None):
685685
686686 def _init_toolbar (self ):
687687 self .basedir = str (cbook ._get_data_path ('images' ))
688+ # Ensure that zoom and pan are mutually exclusive.
689+ self ._button_group = QtWidgets .QButtonGroup ()
688690
689691 background_color = self .palette ().color (self .backgroundRole ())
690692 foreground_color = self .palette ().color (self .foregroundRole ())
@@ -700,6 +702,7 @@ def _init_toolbar(self):
700702 self ._actions [callback ] = a
701703 if callback in ['zoom' , 'pan' ]:
702704 a .setCheckable (True )
705+ self ._button_group .addButton (self .widgetForAction (a ))
703706 if tooltip_text is not None :
704707 a .setToolTip (tooltip_text )
705708 if text == 'Subplots' :
@@ -774,18 +777,13 @@ def edit_parameters(self):
774777 ax = axes [titles .index (item )]
775778 figureoptions .figure_edit (ax , self )
776779
777- def _update_buttons_checked (self ):
778- # sync button checkstates to match active mode
779- self ._actions ['pan' ].setChecked (self ._active == 'PAN' )
780- self ._actions ['zoom' ].setChecked (self ._active == 'ZOOM' )
781-
782780 def pan (self , * args ):
783781 super ().pan (* args )
784- self ._update_buttons_checked ( )
782+ self ._actions [ 'pan' ]. setChecked ( self . _active == 'PAN' )
785783
786784 def zoom (self , * args ):
787785 super ().zoom (* args )
788- self ._update_buttons_checked ( )
786+ self ._actions [ 'zoom' ]. setChecked ( self . _active == 'ZOOM' )
789787
790788 def set_message (self , s ):
791789 self .message .emit (s )
0 commit comments