# draw_line_xw.py # draw lines, rounded-rectangle, circle in Python wx import wx class MyFrame(wx.Frame): def __init__(self, parent=None, id=-1, title='draw_line_wx.py'): wx.Frame.__init__(self, parent, id, title) self.panel = wx.Panel(self, size=(400,400) ) self.panel.Bind(wx.EVT_PAINT, self.on_paint) self.Fit() def on_paint(self, event): dc = wx.PaintDC(self.panel) # device or drawing context dc.SetPen(wx.Pen('blue', 8) ) # color, width in pixels dc.DrawLine(30,20, 300,20) # x1,y1 to x2,y2 dc.SetPen(wx.Pen('green',1) ) dc.DrawLine(30,20, 30,300) # x1,y1 to x2,y2 dc.SetPen(wx.Pen('red',1) ) # pen outlines rect = wx.Rect(50,50, 200,100) dc.DrawRoundedRectangleRect(rect, 4) dc.SetBrush(wx.Brush('yellow') ) # brush fills dc.DrawCircle(100, 300, 50) # x, y, radius app=wx.PySimpleApp() frame1 = MyFrame() frame1.Center() frame1.Show() app.MainLoop()