[Tutor] Changing text colors on WinXP py2.6.2

Dave Angel davea at ieee.org
Tue Oct 13 17:50:56 CEST 2009



Tim Golden wrote:
> <div class="moz-text-flowed" style="font-family: -moz-fixed">Alan 
> Gauld wrote:
>> "Tim Golden" <mail at timgolden.me.uk> wrote
>>> No. ANSI escapes don't work on Windows. 
>>
>> Wouldn't the ANSI codes work if ANSI.SYS were loaded?
>> I thought you could still load ANSI.SYS it just wasn't normally 
>> there? The help system says you should load it in config.nt with:
>>
>> device=c:\winnt\system32\ansi.sys
>> But I admit I've never tried it - I didn't even like ANSI.SYS when I 
>> was using DOS!
>
>
> (from memory). I'm fairly sure that even that
> no longer works. When this question last came
> up I think we went round that loop and discovered
> that it didn't. Happy to be wrong. :)
>
> TJG
>
>
(Also from memory).   ANSI.SYS is still available in XP, but only for 16 
bit DOS apps. 

See:  http://support.microsoft.com/kb/101875

So it wouldn't be useful for Python apps like the OP had.  In 
particular, you can load a COMMAND.COM shell with ANSI.SYS driver in 
that (16bit) process.

What ought to work is a 3rd party console replacement.  One example of 
such a replacement (from an old established company) is "Take Command" 
(formerly 4NT) from
     http://www.jpsoft.com/

However, it appears that they only support ANSI sequences in output from 
their built-in commands, such as TYPE.  See:
    http://www.jpsoft.com/help/index.htm?ansisupport.htm


Other things to consider:

cygwin
http://www.softpedia.com/get/System/System-Miscellaneous/ANSICON.shtml
http://www.codeplex.com/poshconsole/

I make no promises as to compatibility, safety, or performance, though.  
I haven't used any of these, except older versions of 4NT.

To change text colors in a standard console, you need to use the Console 
API.  Of course, you can change them for the entire console with the 
Properties dialog.

DaveA


More information about the Tutor mailing list