I am working to make a program that will draw a line to the mouse position so that one could track it.
I have used wx.ScreenDC to draw the line and put it in a loop so that a new line is made every time the mouse pointer changes location.
The problem now is that as soon as I change the mouse position a new line comes but not all of the old lines are not removed. I have tried using the .Clear() method but this does not work. this link suggests using .refresh() method but I cannot find that for ScreenDC.
The screenshot is attached and code is also attached
I do not want this excess of lines. How can I remove them?
while True:
class Frame(wx.Frame):
"""docstring for Frame.wx.Frame."""
pass
class App(wx.App):
"""docstring for App"""
def OnInit(self):
(a,b) =win32api.GetCursorPos()
app = wx.App(False)
s = wx.ScreenDC()
p1=wx.CYAN_PEN
a1=round(1.25*a)
b1=round(1.25*b)
s.StartDrawingOnTop()
s.Pen = p1
s.DrawLine(0,0,a1,b1)
s.EndDrawingOnTop()
s.Clear()
return True
if __name__ == '__main__':
app=App()
app.MainLoop()
del app
``
