cursor positioning and color

harald bada at skumbad.nu
Sun Sep 22 10:36:59 EDT 2002


TuxTrax wrote:
> Being new to python, I would like to know how one goes about such 
> tasks as precise cursor positioning and output to screen in color.
> 
> For instance, If I want to print a character or line, at line 10, 
> column 18, in bright white on red, how would I accomplish this?
> 
> Is there a python library specifically for setting up a text screen 
> to look and function the way you want it to, without having to use a GUI?
> 
> The SLRN screen is a good example. Obviously, text positioning and coloring
> commands are being utilized here, as well as such things as clearing
> the screen and controlled scrolling.
> 
> How would these things be done in python, and what reference material is
> available on line? I couldn't find anything in the Python manual, so any
> URL's would be appreciated

well.. there's the curses module. it's a standard module so the docs are 
in the library reference..

or if you just want to do something simple, you can just use ansi escape 
codes directly, so to 'print a character or line, at line 10, column 18, 
in bright white on red', you could write

print "\033[10;18H\033[37;41m" + string

after a quick search on google i found this reference: 
http://www.dee.ufcg.edu.br/~rrbrandt/tools/ansi.html

--
/harald              bada at skumbad.nu             http://bada.skumbad.nu/

makt leder till missbruk.




More information about the Python-list mailing list