A console based graphics engine for simple Unicode games and animations.
Failed to load latest commit information.
examples Move examples into directory Feb 10, 2016
graphics PEP8 Jun 25, 2015
.gitignore Added sublime stuff to .gitignore Jan 31, 2014
LICENCE Create LICENCE Feb 10, 2016
README.md Add link to tetris game to readme Feb 10, 2016
setup.py Version 1.1 Feb 10, 2016


Python Text Based Graphics Module

This is a console based python3 graphics engine for simple Unicode games or animations.

clock.py, terrain.py, road.py, input_example.py and circle.py are example programs using the module (Note: < and > are used instead of arrow keys.), also see grit96's Physics Engine and my Tetris game, which use this module.

terrain.py road.py clock.py


Install using setup.py:

python3 setup.py install

Or install from PyPI: pypi.python.org/pypi/graphics.


Simple usage example:

import graphics as g

# Create the canvas, 20x20 pixels (characters).
screen = g.Canvas(size = (20, 20))

# Create a circle image, radius 5 pixels.
circleImage = g.shapes.Circle(5)

# Create a green sprite at position (7, 7) with the circle image.
circleSprite = g.Sprite(circleImage,
                        position = (7, 7),
                        color = g.colors.GREEN)

# Add the sprite to the canvas.

# Output the canvas to the terminal.

# Increase the circles radius by two.
circleSprite.image.radius += 2

# Output the canvas to the terminal.


This module was written and tested with python3 on Debian with gnome-terminal. It should work with most Linux terminals, but some things might be off.

  • Colours should work if your terminal supports them, otherwise they won't cause any problems.
  • The input module supports Windows, Mac and Unix. Linux works fine and testing is in progress for Windows.
  • In the Windows CMD it doesn't centre properly, colours don't work, it was slow and input doesn't work.

console.py is a small script to determine the terminal size. Works in my gnome-terminal in Debian, probably wont work in all environment. It was modified from Stack Overflow.

colors.py has functions for adding the correct escapes to strings to color them, modified from a blog, also not sure about environment support.

nbinput.py an object to get non blocking input in the terminal, this only works in Linux terminals. This was modified from code.activestate.com.

Bitdeli Badge