Hi,
I'm building a simple wxpython + matplotlib application using wxmpl (no pylab).
I'm currently trying to get X and Y coordinates of a point I click inside a graph plotted in a PlotPanel.
So I'm trying to connect the PlotPanel to a button_press_event. The problem is it fails silently. No error, but it seems that the connected function is never called and even that the connecting itself never happens.
My hypothesis: I see that the PlotPanel has default zooming when selecting a box with the mouse, so I think it is already connected with button_press_event? should I disconnect? how (what's the id)? Should I use something different from PlotPanel?
···
-------------------
Here are relevant code snippets:
class MainWindow(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,ID_FRAME,title,size=(800,600),style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
self.control=wxmpl.PlotPanel(self,1)
[Then, if I send the right wxpython event (I want my plot giving me coordinates only when I say the gui to do it), I call ClickPlot, that should turn on the connection between the mpl event 'button_press_event' and another function, for my PlotPanel.]
def ClickPlot(self,event):
#test code
print 'you're calling ClickPlot()'
def click_me(mpl_event):
#test code
print 'you click me!'
if mpl_event.inaxes:
print 'in axes too!'
disconnect_id=self.control.mpl_connect('button_press_event',click_me)
--------------------------
I checked and ClickPlot() is called, but as said before, click_me() is not. Any idea? What could I do to figure out what's (not) happening?
Thanks,
Massimo
--
Massimo Sandal
University of Bologna
Department of Biochemistry "G.Moruzzi"
snail mail:
Via Irnerio 48, 40126 Bologna, Italy
email:
massimo.sandal@...898...
tel: +39-051-2094388
fax: +39-051-2094387