python - Event handling for matplotlib figure inside a WxPython panel -


how event handling on matplotlib figure inside notebook or example this?

from numpy import arange, sin, pi import matplotlib matplotlib.use('wxagg')  matplotlib.backends.backend_wxagg import figurecanvaswxagg figurecanvas matplotlib.backends.backend_wx import navigationtoolbar2wx matplotlib.figure import figure  import wx  class canvaspanel(wx.panel):     def __init__(self, parent):         wx.panel.__init__(self, parent)         self.figure = figure()         self.axes = self.figure.add_subplot(111)         self.canvas = figurecanvas(self, -1, self.figure)         self.sizer = wx.boxsizer(wx.vertical)         self.sizer.add(self.canvas, 1, wx.left | wx.top | wx.grow)         self.setsizer(self.sizer)         self.fit()      def draw(self):     t = arange(0.0, 3.0, 0.01)     s = sin(2 * pi * t)     self.axes.plot(t, s)   if __name__ == "__main__":     app = wx.pysimpleapp()     fr = wx.frame(none, title='test')     panel = canvaspanel(fr)     panel.draw()     fr.show()     app.mainloop() 

tried self.canvas.mpl_connect('pick_event', onpick) showing error saying ".pynoapperror: wx.app object must created first!"


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -