I am trying to make a GUI interface for a plotting routine written with matplotlib. The GUI is in PyGtk. One of the things I would like to have is a cross hair through the mouse cursor (a vertical and horizontal line intersecting at the mouse) which moves along with the cursor (as long as it's on the plot) I have used matplotlib.backend_gtkagg to embed the figure into a gtk widget:
#!/usr/bin/python #Filename: foo.py import pygtk pygtk.require('2.0') import gtk import matplotlib matplotlib.use('GtkAgg') from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as Canvas import pylab class PyApp(gtk.Window): def __init__(self): super(PyApp, self).__init__() self.fig = matplotlib.pyplot.figure() self.ax = self.fig.add_subplot(1,1,1) self.canvas = Canvas(self.fig) self.canvas.set_size_request(800,600) self.canvas.mpl_connect('motion_notify_event', self.on_drawarea) self.pltbox = gtk.VBox(False, 0) self.pltbox.pack_start(self.canvas) self.add(self.pltbox) self.connect("destroy",gtk.main_quit) self.show_all() def on_drawarea(self,event): if event.xdata != None: print event.xdata,event.ydata PyApp() gtk.main()
Does anybody have any ideas on how to help me? Thank you!