Python Chess, v 0.4 – Better graphics, Tkinter

 The latest version of Python Chess is looking pretty slick!


I found the public domain chess graphics at Wikimedia Commons:  Adding them into Python Chess just required a resize, which Pygame handles very easily with the pygame.transform.scale function.  I also added the labels around the board so it is easier to interpret the “move reports” in the scrolling text box on the right.  Oh, and I also cleaned up those messages, too. 

The other big addition is that I incorporated a little Tkinter, as promised.  Before the main pygame window displays, a Tkinter dialog box pops up to get the game parameters — player names and types (human or AI).


In my previous post, I said something about perhaps changing my scrolling text box to something slicker and already implemented.  Well, it seems that it is not possible (or at least tricky and not recommended) to use pygame in conjunction with a windows manager because of their conflicting event loops.  I googled around and found some ways people can get it to work, but the methods all were dubious looking hacks.  There is a window manager project created within pygame called PGU GUI which might be useful for future projects.  For now, I’ll content myself with the Tkinter window at the beginning of my program and not worry about changing the scrolling text box.

Incidentally, while looking into Tkinter, I discovered wxPython.  There is a comprehensive demo available when you download wxPython which goes through a lot of the possible gui functionality.  Looks pretty amazing!  There is a lot you can do there.  In fact, I think that Python Chess could have been easily done in just wxPython (or Tkinter for that matter) and look just as good as it does using Pygame (Python Chess is not exactly a graphical powerhouse).  I guess Tkinter is nice because it is a standard Python library.  But Guido van Rossum (the guy who created Python), is quoted on the wxPython website as saying:

wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn’t the standard Python GUI toolkit is that Tkinter was there first.

From what I can tell from the wxPython demo, I think agree!  Now I want to use wxPython in a future project….

Here’s Python Chess, version 0.4:

The only thing remaining to do is add in better AI!

One response

  1. Nice work! I would agree that a game of this type could easily be implemented with a pure widget-based GUI like Tkinter or wxPython.

    I’ve heard good things about PyGTK for those in a GNOME environment, but as you’re running Windows there I guess that’s not much use to you!

What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: