Hello,

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) :
            return
        return matplotlib.widgets.RectangleSelector.press(self,event)


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
        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
        return 
matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg.press_zoom(self,event)

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

    def zoom(self,*args):
        x = 
matplotlib.backends.backend_gtkagg.NavigationToolbar2GTKAgg.zoom(self,*args)
        self.canvas.widgetlock.release(self)
        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,

              Bernard

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to