|
From: Schalkwyk, J. <Joh...@sc...> - 2004-06-28 14:40:34
|
I've been using matplotlib in a WX application. The particular application
can uses many matplotlib figures within a MDI window class. The problem
appears when there are about seven windows active in the MDI, and an eight
is added. This causes a repaint of all seven matplotlib figures, which then
triggers the following assertion
PyAssertionError: C++ assertion "wxAssertFailure" failed in
"..\src\msw\dcmemory.cpp (133): Couldn't select a bitmap into wxMemoryDC
This appears on windows XP professional, Python 2.3, wxPython 2.5.1.5,
matplotlib 0.54.
The code snippet below reproduces the problem. Basically calling "show()" in
a loop forces repaint of the same window many times. After a while a strange
stack trace appears with the assertion above. Sometimes the stack trace
creates garbage all over the screen which has to be cleared by repainting
the whole screen.
import wx
import matplotlib
matplotlib.use('WX')
from matplotlib.matlab import *
class App(wx.App):
"""Application class."""
def OnInit(self):
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
l = plot(t, s, linewidth=1.0)
xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
legend('line', loc='upper right')
for i in range(100):
grid(True)
show()
# end for
return True
#---------------------------------------------------------------------------
# run the app
app = App()
app.MainLoop()
|