A rajz eseményhez a self.OnPaint() függvényt rendeljük:
self.Bind(wx.EVT_PAINT, self.OnPaint)
Az OnPaint metódusban készítünk egy dc objektumot. Erre rajzolunk.
def OnPaint(self, e): dc = wx.PaintDC(self.panel1) # ide jönnek a rajzok
dc = wx.PaintDC(self.panel1) brush = wx.Brush('white') dc.SetBackground(brush) dc.Clear()
color = wx.Colour(255, 0, 0) b = wx.Brush(color) dc.SetBrush(b) points = [ (100, 100), (150, 150), (50, 150), (100, 100) ] dc.DrawPolygon(points)
def OnPaint(self, e): dc = wx.PaintDC(self.panel1) color = wx.Colour(0, 255, 0) pen = wx.Pen(color) dc.SetPen(pen) dc.DrawLine(100, 50, 100, 150)
def OnPaint(self, e): dc = wx.PaintDC(self.panel1) color = wx.Colour(0, 255, 0) bru = wx.Brush(color) dc.SetBrush(bru) dc.DrawText('Helló Világ', 50, 50)