[wxPython-users] First wxpython program: a sudoku program

Christopher Barker Chris.Barker at noaa.gov
Thu Oct 5 09:23:56 PDT 2006


Jason Wang wrote:
> Thank you so much for the suggestions! I've modified the program
> according to the suggestions and is expanding the program to do more,
> with any luck, i might even make it a full featured puzzle solver :D

This got me interested, so I started with what you last posted, =

implemented my own suggestions, and a bunch more, and now have the enclosed.

A few notes:

It uses a numpy-based class for storing the puzzle, including methods =

for checking for validity of the rows, columns and boxes. This =

demonstrates some of the power of numpy arrays:
   - a 2-d array is a natural way to store this puzzle
   - you can pull slices out of that array, using a view to the same =

data, for rows, columns and the boxes.

I re-did the gui to draw the grid differently. Instead of drawing =

rectangles, I draw a bunch of lines where needed. It also calculates the =

geometry in the OnSize method, then stores that for use in drawing and =

figuring out where the mouse is clicked, etc.

I have not implemented Robin's suggestion to only re-draw the part of =

the puzzle that has changed -- that is a good idea, but computers are so =

fast now that I haven't bothered.

The gui now highlights any rows, columns, or boxes that are invalid.

When you've got something you like, make sure to put it in the Wiki or =

something -- there's some good stuff here.

enjoy!

-Chris






-- =

Christopher Barker, Ph.D.
Oceanographer
                                     		=

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

Chris.Barker at noaa.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sudoku-chb.py
Type: text/x-python
Size: 9873 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20061=
005/0572a805/sudoku-chb.py


More information about the wxpython-users mailing list