wxPython widget flashing

Okay, so back to my sudoku solver...it's got a 9x9 grid of button, and
when the mouse is over a button, it creates a new 3x3 grid of smaller
buttons or static text boxes (haven't decided yet) on the button, so
that the user can quickly select numbers for each button. When the
mouse moves off of the button, it destroys the last 3x3 grid and
creates a new one on the next button. The only problem is, they flash
pretty badly. Is there any way to get around the flashing?

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Your 3x3 grid are widgets that are children of the button? If so that may be part of the problem, most native widgets like buttons were not meant to have children. For something like a sudoku game you'll probably be much better off to just draw everything yourself rather than use widgets for each element. Then you can use double buffered drawing to eliminate flicker, and even add in some animation later on if you're feeling adventurous.

···

On 4/30/10 8:34 AM, Kevin wrote:

Okay, so back to my sudoku solver...it's got a 9x9 grid of button, and
when the mouse is over a button, it creates a new 3x3 grid of smaller
buttons or static text boxes (haven't decided yet) on the button, so
that the user can quickly select numbers for each button. When the
mouse moves off of the button, it destroys the last 3x3 grid and
creates a new one on the next button. The only problem is, they flash
pretty badly. Is there any way to get around the flashing?

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Okay cool, so what exactly do you mean by using my own images? Like a
bitmap button? Or use PIL or what? And i haven't the slightest clue
what double buffering is or how to use it

···

On Apr 30, 12:07 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 4/30/10 8:34 AM, Kevin wrote:

> Okay, so back to my sudoku solver...it's got a 9x9 grid of button, and
> when the mouse is over a button, it creates a new 3x3 grid of smaller
> buttons or static text boxes (haven't decided yet) on the button, so
> that the user can quickly select numbers for each button. When the
> mouse moves off of the button, it destroys the last 3x3 grid and
> creates a new one on the next button. The only problem is, they flash
> pretty badly. Is there any way to get around the flashing?

Your 3x3 grid are widgets that are children of the button? If so that
may be part of the problem, most native widgets like buttons were not
meant to have children. For something like a sudoku game you'll
probably be much better off to just draw everything yourself rather than
use widgets for each element. Then you can use double buffered drawing
to eliminate flicker, and even add in some animation later on if you're
feeling adventurous.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visithttp://groups.google.com/group/wxPython-users?hl=en

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Okay cool, so what exactly do you mean by using my own images? Like a
bitmap button? Or use PIL or what?

Basically you catch the EVT_PAINT event for a window and draw in it whatever you want using a device context object. You'll also want to deal with mouse events so you can respond to clicks, motion, drags, etc. There are several examples of this in the demo and on the wiki (I like http://wiki.wxpython.org/BubblesToy) and Chris Barker also posted a sudoku example in a response to your earlier thread.

And i haven't the slightest clue
what double buffering is or how to use it

Drawing to a bitmap first and then blasting that bitmap to the display in a single step. That way there is no chance for the user to see the intermediate steps, like clearing the window, drawing each of the various parts, etc. Flicker on Windows is usually due to things like that.

···

On 4/30/10 12:29 PM, Kevin wrote:

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Okay cool, so what exactly do you mean by using my own images? Like a
bitmap button? Or use PIL or what?

You can either draw with wx.DC or wx.GraphicsContext, or make the bitmaps with any other external tool (the GIMP, InkScape, whatever), then then load them and render them as Bitmap with wxPython.

There are several examples of this in the demo and on the wiki (I like http://wiki.wxpython.org/BubblesToy)

http://wiki.wxpython.org/DoubleBufferedDrawing

and Chris Barker also posted a sudoku example in a response to your earlier thread.

Why not start with that and make it prettier?

-Chris

···

On 4/30/10 12:29 PM, Kevin wrote:

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Kevin wrote:

Okay cool, so what exactly do you mean by using my own
images? Like a bitmap button? Or use PIL or what? And i
haven't the slightest clue what double buffering is or how to use it

FWIW, attached is my version of a widget that draws a sudoku grid.

It is part of a larger 'solver' program, but I have stripped out all of the
solver code. I did not write that part myself, I just wrote a gui wrapper
around an existing command-line program.

It is designed to make it easy for a user to enter the opening grid using
the numeric keypad. It has some rough edges, particularly if they use the
backspace key to correct a mistake. I never got around to improving this.

Hopefully it will give you some ideas.

Frank Millman

sudoku_grid.py (5.87 KB)

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en