I've written this small app that draws lines between two points selected by the user and it works but how do I keep the lines I draw from disappearing whenever the window is minimized or gets covered by another open window?
class SimpleDraw(wx.Frame):
def __init__(self, parent, id, title, size=(640, 480)):
self.points = []
wx.Frame.__init__(self, parent, id, title, size)
self.Bind(wx.EVT_LEFT_DOWN, self.DrawDot)
self.SetBackgroundColour("WHITE")
self.Centre()
self.Show(True)
def DrawDot(self, event):
self.points.append(event.GetPosition())
if len(self.points) == 2:
dc = wx.ClientDC(self)
dc.SetPen(wx.Pen("#000000", 10, wx.SOLID))
x1, y1 = self.points[0]
x2, y2 = self.points[1]
dc.DrawLine(x1, y1, x2, y2)
# reset the list to empty
self.points = []
if __name__ == "__main__":
app = wx.App()
SimpleDraw(None, -1, "Title Here!")
app.MainLoop()