how to draw in a window, device context

7stud bbxx789_05ss at yahoo.com
Mon Jun 4 01:33:39 PDT 2007


Hi,

I am trying to draw a circle.  After reading about how to draw in a window
 with device contexts in "wxPython In Action ", the following is what I came 
up with.  Of course it doesn't work.  Why?  Also, could someone explain 
each line that needs to be added?

Thanks


import wx

class MyFrame(wx.Frame):
    def __init__(self, mytitle):
        wx.Frame.__init__(self, None, title=mytitle)

        panel1 = wx.Panel(self)
        dc = wx.ClientDC(panel1)
        dc.SetBackground(wx.Brush("black"))
        dc.SetPen(wx.Pen("red") )

        buffer = wx.BufferedDC(dc)
        buffer.DrawCircle(50, 50, 40)

       
class MyApp(wx.App):
    def __init__(self):
        wx.App.__init__(self, redirect=False)


app = MyApp()

win = MyFrame("Test")
win.Show()

app.MainLoop()






More information about the wxpython-users mailing list