naviguation toolbar, box/lasso selector and widget locking


For an application, I am writing, I need the naviguation toolbar 2 and
the BoxSelector and Lasso widgets. The user should be able to select
with the Lasso or BoxSelector widget even when zoom or pan is active
by pressing a modifier key.
I have managed to do this with the following code (for now, only for
the Box selector with modifier key shift):



class ShiftBoxSelector(matplotlib.widgets.RectangleSelector):
    def press(self, event):
        if ((event.guiEvent.state & gtk.gdk.SHIFT_MASK)!=gtk.gdk.SHIFT_MASK) :

class NoShiftNavigationToolbar2(matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg):
    def press_pan(self, event):
        if ((event.guiEvent.state & gtk.gdk.SHIFT_MASK)==gtk.gdk.SHIFT_MASK) :
        return matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg.press_pan(self,event)

    def press_zoom(self, event):
        if ((event.guiEvent.state & gtk.gdk.SHIFT_MASK)==gtk.gdk.SHIFT_MASK) :
        return matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg.press_zoom(self,event)

    def pan(self,*args):
        x = matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg.pan(self,*args)
        return x

    def zoom(self,*args):
        x = matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg.zoom(self,*args)
        return x


Is this a good solution?

My application is not threaded and the only other widgets interacting
with the plots are gtk buttons. However there will be several plots in
different tabs each with their own naviguation toolbar, boxselector
and lasso widgets. What are the risks of unlocking the canvas when
zoom/pan is active?

Thank you for your help,