Simple board game GUI framework

Rick Johnson rantingrickjohnson at gmail.com
Wed Sep 13 00:39:56 EDT 2017


Terry Reedy wrote:
> Paul Moore said:
[...]
> I was going to suggest tkinter.

I would second Terry's advice here. If a low barrier and
simplicity are what you want, then i would suggest tkinter
first and Pygame second. You can do a lot with a tk.Canvas
widget, and for proper image support make sure to install
the third party PIL library. If neither of those are
interesting to you, then you can try any of the third party
GUI or game libraries all the way down to PyOpenGL, where
you get ultimate control, for the small price of your
sanity. (insert maniacal laugh track here)

> > The following code is basically the core of what I need:
> > 
> > import tkinter as tk
> > 
> > def create_board(root):
> >      board = {}
> >      for r in range(8):
> >          for c in range(8):
> >              lbl = tk.Button(bg="white", text="   ", font=("Consolas", 12))
> >              lbl.grid(row=r, column=c)
> >              board[r,c] = lbl

Dude, that tuple is naked! And nudity in public places is
not cool; unless of course your code is a Ms. America model,
or it resides in a nudist colony (Hey, don't forget your
"sitting towel"!), which obviously is not true in either
case. ;-) Try this instead:

                 board[(r,c)] = lbl

There. And now, and in more ways than one, we have defined some
bondaries.



More information about the Python-list mailing list