Pygcurse (pronounced "pig curse") is a curses library emulator that runs on top of the Pygame framework. It provides an easy way to create text adventures, roguelikes, and console-style applications. The mascot of Pygcurse is a blue pig with a skull tattoo on its butt.

"We already have a curses module for Python."

Yes. But unfortunately, the curses module that comes with the Python standard library does not work on Windows. The excellent Console module from effbot provides curses-like features, but it only runs on Windows and not Mac/Linux. By using Pygame, Pygcurse is able to run on all platforms. Also, since this curses-like module is built on top of Pygame, your programs are not strictly limited strictly to text characters. You can use all the normal Pygame drawing and graphics functions, as well as any libraries made for Pygame.

Pygcurse provides several benefits over normal text-based stdio programs:

  1. Color text and background.
  2. The ability to move the cursor and print text anywhere in the console window.
  3. The ability to make console apps that make use of the mouse.
  4. The ability to have programs respond to individual key presses, instead of waiting for the user to type an entire string and press enter (as is the case with input()/raw_input()).
  5. The ability to use any font and any character in those fonts.
  6. Since the console window that Pygcurse uses is just a Pygame surface object, additional drawing and transformations can be applied to it. Multiple surfaces can also be used in the same program.

Pygcurse also provides some additional features that curses normally doesn't, such as tinting, shadows, textboxes, and line drawing functions.

Pygcurse requires Pygame to be installed. Pygame can be downloaded from http://pygame.org. Pygcurse can be used with either Python 2 or Python 3.

If you make your own games with Pygcurse, then send them to @Pygcurse to be publicized!

Download

pygcurse_src.zip, 38 KB (Requires Python 2 or 3 and Pygame to be installed.)

To learn how to write programs with Pygcurse, READ THE TUTORIAL.

Simply download the pygcurse.py file and import pygcurse to make use of it. The download comes with several demo programs.

You can also pull the files off of github: https://github.com/asweigart/pygcurse


Pygcurse is available under a Simplified BSD License. 

Tutorial

There is a tutorial for Pygcurse where you can learn how to use it.

If you don't know how to use Pygame (or Python or programming in general), there is a Pygame tutorial in the free book "Invent Your Own Computer Games with Python"

Screenshots of the Included Demo Programs

Dodger Game (source, Windows exe)

Maze Game (source, Windows exe)

Textris Game (source, tetrisb.mid, tetrisc.mid, Windows exe)

Textbox Test (source)

Shadow Test (source)

Tic Tac Toe Game (source)

Reversi Game (source)

Contributing

If you know Python and want to contribute to this open source project, there are plenty of ways to help out. The main way would be to create your own demo programs with the Pygcurses library, or suggest and develop new features (especially drawing functions and UI controls.) Contact Al at [email protected] if you are interested.

Copyright © 2011. Designed by Free Flash Templates
Pygcurse is released under a Simplified BSD license.