[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] InteractiveConsole



Edward Povazan wrote:

Anyone know how to get a console to work with PyGame.
I want an embedded interpreter/console that I can use to add commands to my
editor - much faster to add a load() and save() functions into an
interpreter, than write a nice GUI etc. But I want to use a simple stupid
shell ie dos box.
I searched the archives, and didn't see anything - has anyone managed a
simple hack? Before I reinvent the wheel :)

Thanks



The absolute easiest way to do this would be to enter information in via stdin/stdout. The problem comes from blocking. You could probably do better by just selecting on stdin and building a string as input comes in and processing when a new line character was received. You would select poll in the main loop of the game.

There are a few text box implementations, see pyui. You could modify one of these to do what you want.

There are others on here with a lot more pygame experience than myself, but these are the most obvious ways to me.

robert