Image Display Problems in Double Buffered Windows

Hello, everyone.

I have code at http://snow.cs.siue.edu/~unix/othello.tgz, and it's my
first time writing wxPython code. I followed the Double Buffering
Window tutorial at wxPython.org in the hopes to reduce flicker whenever
I decide to implement resizing.

Anyway, when my program starts, my pieces look like they're not in the
correct spots (the 4 center pieces). However, if you click on the 4
center pieces, your console will display "Square owned by" and one of
'white' or 'black'. Any other square that isn't a center piece,
including squares that look like they have a piece in them will say
"Square owned by nobody."

If you hit "Restart", the screen then displays properly. However, if
you hide the window under another window and then re-focus it, the
images are again all screwed up. AND, this only seems to be affecting
my double-buffered windows, nothing else on the window.

I've spent probably 24 hours trying to work this problem out, and I'm
not making any progress with it. Have one of you had this problem
before, and if so, what was the solution? Is it something I'm doing
wrong in my class inheritance, or something I'm missing? I've checked
and rechecked the code, and I've seemed to narrow it down to the images
just not showing correctly and confirmed that's the only problem.

Please, if any of you has any idea on this I would GREATLY appreciate
it. Thanks SO much!

I'm not subscribed to this list; so, if you could please email me
directly as well, that would be excellent. I'll make sure I respond to
the list as well in order to keep this in the open.

···

--
William Michael Grim
Student, Southern Illinois University at Edwardsville
Unix Network Administrator, SIUE, Computer Science dept.
Phone: (217) 341-6552
Email: wgrim@siue.edu

First you should consider stating your platform, I tried your code on WinXP SP1 with wxpython 2.5.3.1u on python 2.3.4 and I couldn't reproduce what you've described.
I've seen some decoupling but, IMHO, you should do something like:
create one renderer that will paint your board, that rendered should know how to draw an empty cell, a cell with a white piece and a cell with a black piece. Consider using somethig like dc.DrawBitmap for the black and white pieces and maybe dc.DrawRectangle for the empty ones... alternatively you could draw the entire background in your favorite image editing program and then use DrawBitmap for the background too. Draw all of this on a MemoryDC and then blit it on your PaintDC. consider buffering the drawing and redraw only on resize or on structural change (a piece moves).
Bottom line... the board should be only one wxpython widget, a wx.Panel or a wx.Window not a bunch of small ones.
Also... look at pygame... :wink:

···

On Sun, 19 Dec 2004 07:49:45 -0600, William M. Grim <wgrim@siue.edu> wrote:

Hello, everyone.

I have code at http://snow.cs.siue.edu/~unix/othello.tgz, and it's my
first time writing wxPython code. I followed the Double Buffering
Window tutorial at wxPython.org in the hopes to reduce flicker whenever
I decide to implement resizing.

--
Peter Damoc
jack of all trades, master of none
http://www.sigmacore.net/