[Tkinter-discuss] self modifying buttons - memory game
brewerofbeer at hotmail.com
Wed May 30 15:32:56 CEST 2007
Thanks for the interest and the comments. I didn't have the time or
motivation to try to make it work with arbitrary sizes. I had to turn it in
for a class. I don't know if its in the version I posted, but the version I
handed in had an initial set of buttons where you could select one of three
Cameron Laird-2 wrote:
> 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
>> It is just a version of a memory game where you have a grid of cards and
>> 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.
>> you do both those buttons will stay that color. If your second pick does
>> 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] % len(c)]
> B. You can replace
> col = 
> for z in range(w*h):
> col = range(w * h)
> C. I think what you're *really* after, though,
> # Make copies of the color list to
> # fill out the whole grid, then
> col = (c * (1 + t / len(c)))[:t]
> # shuffle the colors.
> 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
> Tkinter-discuss at python.org
View this message in context: http://www.nabble.com/self-modifying-buttons---memory-game-tf3693914.html#a10873431
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
More information about the Tkinter-discuss