@@ -678,8 +678,6 @@ def _icon(self, name, color=None):
678
678
679
679
def _init_toolbar (self ):
680
680
self .basedir = str (cbook ._get_data_path ('images' ))
681
- # Ensure that zoom and pan are mutually exclusive.
682
- self ._button_group = QtWidgets .QButtonGroup ()
683
681
684
682
background_color = self .palette ().color (self .backgroundRole ())
685
683
foreground_color = self .palette ().color (self .foregroundRole ())
@@ -695,7 +693,6 @@ def _init_toolbar(self):
695
693
self ._actions [callback ] = a
696
694
if callback in ['zoom' , 'pan' ]:
697
695
a .setCheckable (True )
698
- self ._button_group .addButton (self .widgetForAction (a ))
699
696
if tooltip_text is not None :
700
697
a .setToolTip (tooltip_text )
701
698
if text == 'Subplots' :
@@ -754,13 +751,20 @@ def edit_parameters(self):
754
751
ax = axes [titles .index (item )]
755
752
figureoptions .figure_edit (ax , self )
756
753
754
+ def _update_buttons_checked (self ):
755
+ # sync button checkstates to match active mode
756
+ if 'pan' in self ._actions :
757
+ self ._actions ['pan' ].setChecked (self ._active == 'PAN' )
758
+ if 'zoom' in self ._actions :
759
+ self ._actions ['zoom' ].setChecked (self ._active == 'ZOOM' )
760
+
757
761
def pan (self , * args ):
758
762
super ().pan (* args )
759
- self ._actions [ 'pan' ]. setChecked ( self . _active == 'PAN' )
763
+ self ._update_buttons_checked ( )
760
764
761
765
def zoom (self , * args ):
762
766
super ().zoom (* args )
763
- self ._actions [ 'zoom' ]. setChecked ( self . _active == 'ZOOM' )
767
+ self ._update_buttons_checked ( )
764
768
765
769
def set_message (self , s ):
766
770
self .message .emit (s )
0 commit comments