Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wxPython or pygame for a simple card game?

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?

like image 643
adam Avatar asked Mar 12 '09 00:03

adam


3 Answers

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.

like image 185
Robert P Avatar answered Sep 28 '22 06:09

Robert P


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.

like image 29
user24877 Avatar answered Sep 28 '22 06:09

user24877


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.

like image 22
Eli Bendersky Avatar answered Sep 28 '22 08:09

Eli Bendersky