My guess is that clicking on a collection causes a pick event to be returned
by the collection itself and also perhaps by the barh member in the
collection.  No idea if that's the case, but just for the record, I figured
out a simple enough workaround in which the pick handler is disconnected to
open a wxPython popup window.  Once that window is closed, the pick handler
is reconnected:

    self.evt_bind = self.canvas.mpl_connect('pick_event', self.on_pick)
    . . . .
    def on_pick(self, event):
        if type(event.artist) == brokenbarh:
            self.canvas.mpl_disconnect(self.evt_bind)
            popup = popupwin(self, event.mouseevent.xdata,
event.mouseevent.ydata)
            popup.Popup()

class popupwin(wx.PopupTransientWindow):
    def __init__(self, plot, x_coord, y_coord):
        wx.PopupTransientWindow.__init__(self, plot)
        self.plot = plot
        text = st.gen(self, 'hello')

    def OnDismiss(self):
        self.plot.evt_bind = self.plot.canvas.mpl_connect('pick_event',
self.plot.on_pick


On Sun, Jun 22, 2008 at 1:18 AM, Paul Hartley <[EMAIL PROTECTED]> wrote:

>
> If I click on a bar that is part of a broken_barh collection which has its
> picker attribute enabled, there appears to be two events generated for
> example:
>
>     def on_pick(self, event):
>         print event.mouseevent.xdata
>         print event.mouseevent.ydata
>
> clicking on a bar will cause this method to be executed twice, hence I get
> something like this if I click just once:
>
> 5575.97222222
> 0.0277777777778
> 5575.97222222
> 0.0277777777778
>
> Is there a workaround such that the method is executed only once?
>
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to