Interactive blit / animation


Would like to understand the "best" way to animate / move text on an wxAgg
frame. The following demo code adds text to a random location for each
button interrupt. How best to change this code so that the text is added
only once, and then efficiently move this text to a new random location
for each button interrupt (using perhaps blit, without recreating the
canvas??)? If this has been answered before, please point me to the
thread. Thank you, Doug.


class MyNavigationToolbar(NavigationToolbar2WxAgg):
  ON_CUSTOM = wx.NewId()
  def __init__(self, canvas):
    NavigationToolbar2WxAgg.__init__(self, canvas)
    self.AddSimpleTool(self.ON_CUSTOM, _load_bitmap('stock_left.xpm'),
'Click me')
    wx.EVT_TOOL(self, self.ON_CUSTOM, self._on_custom)

  def _on_custom(self, evt):
    ax = self.canvas.figure.axes[0]
    x,y = tuple(np.random.rand(2))
    rgb = tuple(np.random.rand(3))
    ax.text(x, y, 'You clicked me', transform=ax.transAxes, color=rgb)
toolbar = MyNavigationToolbar(canvas)