Python Chess, v 0.4 – Better graphics, Tkinter

 The latest version of Python Chess is looking pretty slick!

python_chess_v04_mainwindow1

I found the public domain chess graphics at Wikimedia Commons: http://commons.wikimedia.org/wiki/File:Chess_tile_pd.png.  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).

python_chess_v04_tkinter

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: PythonChess_v0.4.zip

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

About these ads
Post a comment or leave a trackback: Trackback URL.

Comments

  • Rawlyn  On May 6, 2009 at 6:05 AM

    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!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: