wxPython wx.BufferedPaintDC versus wx.PaintDC to draw a NumPy array

I have wxPython imaging question on stackoverflow.com I'm hoping
someone can help me with.

http://stackoverflow.com/questions/8618167/wxpython-wx-bufferedpaintdc-versus-wx-paintdc-to-draw-a-numpy-array

Nutshell: I'm leveraging the Double Buffered Drawing example at [1]
but using a NumPy array as described in [2]. I'm getting a blank white
panel when using BufferedPaintDC but get a correct image when using
PaintDC+DrawBitmap.

To confuse myself further, I've found using a wxImage for the NumPy
interface then convert wxImage to wxBitmap for the _Buffer, the
example works.

What am I doing wrong using NumPy and wxBitmap directly with the
double buffered example?

Thanks!

[1] http://wiki.wxpython.org/DoubleBufferedDrawing
[2] http://wiki.wxpython.org/WorkingWithImages

I have wxPython imaging question on stackoverflow.com I'm hoping
someone can help me with.

http://stackoverflow.com/questions/8618167/wxpython-wx-bufferedpaintdc-versus-wx-paintdc-to-draw-a-numpy-array

Nutshell: I'm leveraging the Double Buffered Drawing example at [1]
but using a NumPy array as described in [2]. I'm getting a blank white
panel when using BufferedPaintDC but get a correct image when using
PaintDC+DrawBitmap.

Which platform/version are you using? It seems to be working fine for me on Win7 with wxPython 2.8.12.1 and 2.9.3.1.

I'm not exactly sure yet what is going on with the BufferedPaintDC case in your example, but if you are going to be filling the whole window with the buffer bitmap and nothing else, then using wxPaintDC and DrawBitmap will be just as efficient and flicker-free as BufferedPaintDC.

Also, since you are filling the whole window in the paint event you should try setting the background style to wx.BG_STYLE_CUSTOM (for 2.8) or wx.BG_STYLE_PAINT (for 2.9) and see if that helps. It will prevent the system from trying to erase the window before the paint event. You should probably also get rid of the wx.NO_FULL_REPAINT_ON_RESIZE style in this case too.

To confuse myself further, I've found using a wxImage for the NumPy
interface then convert wxImage to wxBitmap for the _Buffer, the
example works.

Because it is recreating the bitmap for each paint. So perhaps something is clearing the bitmap after the first use...

···

On 12/30/11 7:06 AM, testcluster wrote:

--
Robin Dunn
Software Craftsman