wxPaintCD can be only created in EVT_PAINT handler

Hello,
  I am trying to get a program written with wxPython running in Windows XP. I have a class derived from wxGLCanvas. Whenever I try to map the window that contains the canvas, python gives the following complaint :

Traceback (most recent call last):
   File "C:\Documents and Settings\Jason Mazzotta\Desktop\neveredit\GLWindow.py",
  line 65, in OnPaint
     dc = wxPaintDC(self)
   File "C:\PROGRA~1\PYTHON~1.4\Lib\site-packages\wx\_gdi.py", line 4199, in __in
it__
     newobj = _gdi_.new_PaintDC(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed in ..\..\src\m
sw\dcclient.cpp(221): wxPaintDC may be created only in EVT_PAINT handler!

When the OnPaint method is set as the EVT_PAINT delegate. Is this a known problem with wxPython in Windows? Is there a way around this?

Thanks,

Jason Mazzotta

jason mazzotta wrote:

Hello,
I am trying to get a program written with wxPython running in Windows XP. I have a class derived from wxGLCanvas. Whenever I try to map the window that contains the canvas, python gives the following complaint :

Traceback (most recent call last):
File "C:\Documents and Settings\Jason Mazzotta\Desktop\neveredit\GLWindow.py",
line 65, in OnPaint
dc = wxPaintDC(self)
File "C:\PROGRA~1\PYTHON~1.4\Lib\site-packages\wx\_gdi.py", line 4199, in __in
it__
newobj = _gdi_.new_PaintDC(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed in ..\..\src\m
sw\dcclient.cpp(221): wxPaintDC may be created only in EVT_PAINT handler!

When the OnPaint method is set as the EVT_PAINT delegate. Is this a known problem with wxPython in Windows? Is there a way around this?

Do you call OnPaint directly? (Pay attentention to how you bind the event, you should use self.OnPaint, not self.OnPaint(). )

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!