Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. class SketchWindow(wx.Window):
  2.  
  3. def __init__(self, parent):
  4. wx.Window.__init__(self, parent, -1)
  5. self.SetBackgroundColour('White')
  6. # Window event binding
  7. self.Bind(wx.EVT_PAINT, self.OnPaint)
  8. self.Bind(wx.EVT_IDLE, self.OnIdle)
  9. # run
  10. self.Run()
  11.  
  12. def OnPaint(self, evt):
  13. self.DrawEntities(wx.PaintDC(self))
  14.  
  15. def DrawEntities(self, dc):
  16. dc.SetPen(wx.Pen('Black', 1, wx.SOLID))
  17. dc.SetBrush(wx.Brush('Green', wx.SOLID))
  18. # draw all
  19. for e in self.entities:
  20. x, y = e.location
  21. dc.DrawCircle(x, y, 4)
  22.  
  23. def OnIdle(self, event):
  24. self.Refresh(False)
  25.  
  26. def Run(self):
  27. # update self.entities ...
  28. # call this method again later
  29. wx.CallLater(50, self.Run)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement