views:

268

answers:

3

I'm pretty new to programming, and I'm creating a simple text-based game.>

I'm wondering if there is a simple way to create my own terminal-type window with which I can place coloured input etc.

Is there a graphics module well suited to this? I'm using Mac, but I would like it to work on Windows as well

Thanks

+1  A: 

You could use the termcolor library - it that what you're looking for?

On Windows things are trickier. See this SO answer - you should resort to win32console and some ctypes. The answer has some code and links to other articles.

Eli Bendersky
I thought that didn't work on Windows???
Jasper
@Jasper: I've updated the answer. HTH
Eli Bendersky
Conceptually the `termcolor` thing is uglier, imho. It's just that probably no one really bothered bringing the Windows console API to Python in a nicely usable way :-)
Joey
@Johannes: I suppose this is because on Windows terminals are far less useful than on other platforms
Eli Bendersky
They have a defined set of capabilities, making things like termcap and terminfo obsolete. And they have a C API instead of a text stream "API". That's about all the differences. All the nice things of ECMA-48 that extend beyond moving the cursor around or changing the color are nowhere implemented in terminal emulators anyway.
Joey
+1  A: 

The Tkinter Text Widget will do what you ask. the IDLE main window is implemented as one, if you want to play with an example.

msw
+1  A: 

For game programming with Python, I would always recommend PyGame. It is not very complex and enables you to easily use input, graphics and sound. As a start:

http://www.penzilla.net/tutorials/python/pygame/

hendrik