Chances are this is a dumb question, but hey, I don't have anywhere else to go. I wrote a basic hangingman game on my pc desktop using a paint event to draw the hangman. Unfortunately, this code doesn't seem to run the same on my new apple computer. It comes back with
<'Hangman has no attribute 'dc'>.

Here's setting up the paint event in a panel:

def on_paint(event):
        self.dc == wx.PaintDC(event.GetEventObject())
        self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

And here's trying to draw something into the event upon the start of a new game:

self.dc.Clear()
        self.dc.SetPen(wx.Pen("BLACK", 4))
        self.dc.DrawLine(200, 350, 500, 350)
        self.dc.DrawLine(300, 350, 300, 50)
        self.dc.DrawLine(300, 50, 400, 50)
        self.dc.DrawLine(400, 50, 400, 125)

Please let me know what I'm doing wrong here.

def on_paint(event):
self.dc == wx.PaintDC(event.GetEventObject())
self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

There error is this method you creadted is not part of the class without the keyword self. try this.......

def on_paint(self,event):
        self.dc == wx.PaintDC(event.GetEventObject())
        self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

And here you go ;)

There error is this method you creadted is not part of the class without the keyword self. try this.......

def on_paint(self,event):
        self.dc == wx.PaintDC(event.GetEventObject())
        self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

And here you go ;)

Tried, but couldn't get it to work. I'll mess with DC events later, I brushed the issue aside with Bitmaps, because hey, I'm a slacker and it's just a Hangman game. Thank you though.

That should have worked 100% for you. There must be somthing again not right with your code. You can post all your code for checkup.
:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.