I have a script which looks at multiple values within a large database, and draws coordinates on a floatcanvas. I also have some thresehold variables attached to a slider widget. As the slider changes the thresehold value, the canvas is redrawn...well...sort of. It draws the new objects over the old, but I can't figure out how to get rid of the old one. I get the error that the object does not have the attribute 'Destroy'. Is there another way to remove/delete an object from a float canvas?
The following isn't the actual code, but illustrates the problem just the same. Thanks again for any suggestions. Cheers.
import wx app = wx.App(0) try: import sys sys.path.append("../") from floatcanvas import NavCanvas, FloatCanvas, GUIMode except ImportError: from wx.lib.floatcanvas import NavCanvas, FloatCanvas, GUIMode class TestFrame(wx.Frame): def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.canvas =FloatCanvas.FloatCanvas(self, BackgroundColor = "DARK SLATE BLUE") # Layout MainSizer = wx.BoxSizer(wx.VERTICAL) MainSizer.Add(self.canvas, 4, wx.EXPAND) self.SetSizer(MainSizer) self.canvas.Bind(FloatCanvas.EVT_LEFT_DOWN, self.OnLeftDown) self.RectN = self.canvas.AddRectangle((10,10), (100, 20), FillColor="red") self.canvas.SetMode(GUIMode.GUIMouse(self.canvas)) wx.CallAfter(self.canvas.ZoomToBB) # Delete rectangle on mouse click def OnLeftDown(self, event): print 'Left Button clicked at:', event.Coords self.RectN.Destroy() frame = TestFrame(None, title="Mouse Event Tester") #self.SetTopWindow(frame) frame.Show(True) app.MainLoop()