Scott Nelson <sirg...@gmail.com> wrote: > > It *is* possible to color console text with Python and pywin. But, it is > tricky and not obvious. I've been wondering how to do this myself and I > recently found some C code on the web [2] that does this and I translated > that into to Python and pywin. It can be done in about 4 lines of Python. >
For the sake of posterity (and the archives), I figured I'd list the "4 lines of Python" I mentioned above: <code> import win32console handle = win32console.GetStdHandle(win32console.STD_OUTPUT_HANDLE) handle.SetConsoleTextAttribute(win32console.FOREGROUND_BLUE) print 'blue text' </code> Beginning with this snippet, there are a number of other things you can do, such as set the cursor position (handle.SetConsoleCursorPosition) and get the properties of the console itself (handle.GetConsoleScreenBufferInfo).
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor