On Mon, May 28, 2007 at 01:46:25PM -0700, RickB wrote:
> >                     .
> >                     .
> >                     .
> >> I assume there is probably a better way to do this. The code is
> >> functional
                        .
                        .
                        .
> http://www.nabble.com/file/8227/gui2.py
> It is just a version of a memory game where you have a grid of cards and you
> have to pick a matching pair. If you click the one of buttons in the grid
> you will see a color. You then must click a button with a matching color. If
> you do both those buttons will stay that color. If your second pick does not
> match, both buttons turn back to gray. I think my new file is pretty
> efficient and functional.
                        .
                        .
                        .
Ah!  I have the new version, and it does indeed entertain
me, and appear to be correct.  While we're here, I'll make
a couple of comments:
A.  I'd likely replace
        col[z]=c[col[z]%5]
    with
        col[z] = c[col[z] % len(c)]
B.  You can replace
        col = []
        for z in range(w*h):
            col.append(z)
    with
        col = range(w * h)
C.  I think what you're *really* after, though,
    is
            # Make copies of the color list to
            # fill out the whole grid, then
        col = (c * (1 + t / len(c)))[:t]
            # shuffle the colors.
        random.shuffle(col)
D.  Similarly, there are ways to recode maker()
    so that it's briefer, easier to understand,
    and less tricky in its global manipulation.
E.  There are choices for c, w, and h that leave
    the "board" unplayable--that is, all pairs
    have been matched, and all that's left are
    unpaired colors.

Nice work!
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to