Skip to main content


Simple interactive terminal for pygame

John Schanck
pygame-console provides a console similar to the one found in games such as Quake 3, which can be imbedded into any pygame application.



Home Page


pygame-console 0.1 — 11 Aug, 2006

pygame-console 0.5 — 13 Sep, 2006

pygame-console 0.7 — 2 Dec, 2006

pygame-console 0.2 — 17 Aug, 2006 account Comments

  • WeevilKnevil 2012-05-02 00:16

    Awesome! Keep going!

  • zoobar 2016-06-20 20:47

    Its a bit buggy when typing non asscii letters. If you actually use unicode letters such as ö,ä the app crashes instantly.

  • zapman 2016-06-21 21:43

    Very useful addition is to integrate support for the localy stored database sqlite. This allows storing the cfg file in a database instead of a flat file. I accomplished this by adding a few lines in the __init__ method and the load_cfg method. Basic idea is that variables are stored in some table in slqite (create table dvars (name text,value text)) and read on start.

    What needs to be changed

    class Console:
    def __init__(self, screen, rect, functions={}, key_calls={}, vars={}, syntax={},database=None):

    self.database = database


    def load_cfg(self):
    Loads the config file path/pygame-console.cfg\
    All variables are initialized to their defaults,\
    then new values will be loaded from the config file if it exists.
    if os.path.exists(cfg_path):
    for line in file(cfg_path):
    tokens = self.tokenize(line)
    if re_is_comment.match(line):
    elif len(tokens) != 2:

    #add database values if any
    if self.database!=None:
    #convert to database if string entered
    if(not hasattr(self.database,"execute")):
    import sqlite3
    self.database = sqlite3.connect(self.database)
    ans = self.database.execute("select name,value from dvars")
    for row in ans:
    aval = row[1]
    aval = eval(row[1])
    except Exception,e:

    #allow any vars to be loaded


  • zapman 2016-06-22 13:52

    Another thing missing from the pyconsole are triggers/callbacks to be called when a variable changes value. This allows you to call a setup function if you change settings that require loading of bitmaps, fonts etc. With some changes of the code changing system variables like "ps1" would instantly change the console settings...
    In other words add a table with a couple of functions that get called when a variable changes in setvar and create some setup function that gets called if any of the console sys parameter changes.

    Furthermore the parsing of some text messages is not working properly, for instance "some 'string2\"escape string\"' " isnt't working as expected. The parsing of text delimiters isnt good enough..

  • zapman 2016-06-23 15:15

    Additional the function output can only take a single argument and requires that input is text.
    Add something like this
    def output(self, *itext):
    text = ""
    for atom in itext:
    text = text + str(atom)