[Tutor] Print to std output with color

Karim karim.liateni at free.fr
Wed Jan 26 20:37:47 CET 2011


Thanks a lot Scott for the tip!

Regards
Karim

On 01/26/2011 07:10 PM, Scott Nelson wrote:
> Curses is one way to go.  Another is to use the PyWin32 module 
> discussed in this thread:
> http://thread.gmane.org/gmane.comp.python.tutor/58450/focus=58454
> Basically, here's a snippet of code that can get you started.  This 
> requires that you have the PyWin32 module installed (already installed 
> by default if you use ActiveState's Python distribution for Windows).  
> Using PyWin32 isn't for the faint of heart, but it does work.
> import win32console
> handle = win32console.GetStdHandle(win32console.STD_OUTPUT_HANDLE)
> handle.SetConsoleTextAttribute(win32console.FOREGROUND_BLUE)
> print 'blue text'
>
> On Wed, Jan 26, 2011 at 11:10 AM, Karim <karim.liateni at free.fr 
> <mailto:karim.liateni at free.fr>> wrote:
>
>
>     Hello all,
>
>     Is there a simple way to print with color to stdout like the
>     unix/linux example below:
>
>     *print( '^[[1;31mThis is a warning!^[[0m' )
>
>     where <Ctrl-V><esc> <=> ^[
>
>     *I see thing with curses module. But is there an more simple
>     object in other module to do the trick?
>     Kind of _/decorate_output( mode=WARNING, *'This is a warning!')*/_
>
>     Regards
>     Karim
>
>     _______________________________________________
>     Tutor maillist  - Tutor at python.org <mailto:Tutor at python.org>
>     To unsubscribe or change subscription options:
>     http://mail.python.org/mailman/listinfo/tutor
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110126/48f4dbc1/attachment.html>


More information about the Tutor mailing list