[Tutor] two questions
alan.gauld@bt.com
alan.gauld@bt.com
Thu Nov 7 18:02:15 2002
> (1) Is it possible to capture key-presses (like: page up, page down,
> aroow keys, etc.) in Python program? In other words, is there a Python
> equivalent of the BASIC Inkey$ function?
>
Yes. Use curses on Unix or msvcrt on windows
Example of latter on my online tutor in the event handling topic.
> (2) Is it possible to change foreground or background colors
> within the Python command line interface? (i.e. not Idle)
That depends on what you are using. If its a paper based teletype
then you can change the background colour by changing the paper!
If its a vt100 series terminal you can use the DEC escape codes.
If its a DOS window then you an use ANSI codes provided ANSI.SYS
is loaded.
The point is that Python doesn't know what kind of terminal you
are using so doesn't know how to change it. These things are not
standardised.
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld