views:

1188

answers:

6

I have been playing around with writing some simple card games in Python for fun and I would like to add a graphical user interface (GUI) to the games. Which library would you recommend for writing the GUI for a simple card game?

+1  A: 

I'd say pygame -- I've heard it's lots of fun, easy and happy. Also, all of my experiences with wxPython have been sad an painful.

But I'm not bias or anything.

David Wolever
+5  A: 

If all you want is a GUI, wxPython should do the trick.

If you're looking to add sound, controller input, and take it beyond a simple card game, then you may want to use pygame.

Robert P
+4  A: 

I haven't used wxPython, but Pygame by itself is rather low-level. It allows you to catch key presses, mouse events and draw stuff on the screen, but doesn't offer any pre-made GUI controls. If you use Pygame, you will either have to write your own GUI classes or use existing GUI extensions for Pygame, like Phil's Pygame Utilities.

+2  A: 

The answers to this related question may be very useful for you:

What can Pygame do in terms of graphics that wxPython can't?

zweiterlinde
+2  A: 

Generally, PyGame is the better option for coding games. But that's for the more common type of games - where things move on the screen and you must have a good "frame-rate" performance.

For something like a card game, however, I'd go with wxPython (or rather, PyQt). This is because a card game hasn't much in terms of graphics (drawing 2D card shapes on the screen is no harder in wx / PyQt than in PyGame). And on the other hand, you get lots of benefits from wx - like a ready-made GUI for interaction.

In Pygame you have to create a GUI yourself or wade through several half-baked libraries that do it for you. This actually makes sense for Pygame because when you create a game you usually want a GUI of your own, that fits the game's style. But for card games, most chances are that wx's standard GUI widgets will do the trick and will save you hours of coding.

Eli Bendersky
It is interesting that you suggested drawing 2D card shapes. I was thinking of using images of cards to represent the cards. Are there any advantages to drawing card shapes versus using images?
adam
@adam: two advantages. (1) you get to learn how to draw non-trivial shapes. (2) you can make the cards look however you wish, not tied to any specific image you find.
Eli Bendersky
+1  A: 

pygame is the typical choice, but pyglet has been getting a lot of attention at PyCon. Here's a wiki entry on Python Game libraries: http://wiki.python.org/moin/PythonGameLibraries

Mike Driscoll