I have the following
class SketchWindow(wx.Window): def __init__(self, parent): wx.Window.__init__(self, parent, -1) self.SetBackgroundColour('White') # Window event binding self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_IDLE, self.OnIdle) # run self.Run() def OnPaint(self, evt): self.DrawEntities(wx.PaintDC(self)) def DrawEntities(self, dc): dc.SetPen(wx.Pen('Black', 1, wx.SOLID)) dc.SetBrush(wx.Brush('Green', wx.SOLID)) # draw all for e in self.entities: x, y = e.location dc.DrawCircle(x, y, 4) def OnIdle(self, event): self.Refresh(False) def Run(self): # update self.entities ... # call this method again later wx.CallLater(50, self.Run)
I need to draw on my window a number of circles [0, 2000] every N milliseconds (50 in my example), where at each step these circles may update their location.
The method I wrote works (the circles are anti-aliased too) but it's quite slow. Is there a way to improve my solution?