I'm seeing this error:
Devices\XRC\py\gui\Pseudo\Controls.py", line 1121, in OnPaint
dc = wx.BufferedPaintDC(self)
File "wx\_gdi.pyo", line 4886, in __init__
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at ..
\..\src\msw\dcmemory.cpp(118) in wxMemoryDC::DoSelect(): Couldn't
select a bitmap into wxMemoryDC Traceback (most recent call last):
File "C:\Program Files\Analog Devices\XRC\py\gui\Pseudo
\Controls.py", line 1121, in OnPaint
dc = wx.BufferedPaintDC(self)
File "wx\_gdi.pyo", line 4886, in __init__
wx._core.PyAssertionError: C++ assertion "m_refData && m_refData-
GetRefCount() == 1" failed at ..\..\src\common\object.cpp(347) in
wxObject::AllocExclusive(): wxObject::AllocExclusive() failed.
This is the OnPaint Method where the exception occurs:
def OnPaint(self, event):
#(w,h) = self.GetClientSize()
dc = wx.BufferedPaintDC(self)#, wx.EmptyBitmap(w, h))
# clear the background of the buffer
bg = wx.Brush(self.GetBackgroundColour())
dc.SetBackground(bg)
dc.Clear()
# use PrepareDC to set position correctly
self.PrepareDC(dc)
# create a clipping rect from our position and size
xv, yv = self.GetViewStart()
dx, dy = self.GetScrollPixelsPerUnit()
x, y = (xv * dx, yv * dy)
w, h = self.GetClientSizeTuple()
r = wx.Rect(x,y,w,h)
# draw to the dc using the calculated clipping rect
self.pdc.DrawToDCClipped(dc,r)
#self.pdc.DrawToDC(dc)
Let me explain what I have in my software:
I have a bunch of scrollwindows within nested notebooks that display a
variety of controls like scroll bars, text controls etc.. The error
above only happens when I load a large number of scrollwindows to the
screen. The strange thing is, I can open up two separate instances of
my main application and this error doesn't happen. It only happens
when I'm working within one instance. So this must mean that this has
nothing to do with a Windows GUI limitation as such.
The error does go away when I pass in an wx.EmptyBitmap to the
BufferedPaintDC constructor as shown in the comment above, but in that
case I get a windows error which says 'Can't add Image to Image list
x:x:x'. I don't have any image files in my application.
Would appreciate any tips or leads.
Thanks a bunch.
Sid