View Single Post
Old Feb 15th, 2007, 12:19 AM   #9
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Quote:
Originally Posted by Sane View Post
Wow. Are you sure? I've seen in a console window, on Windows, different colors for different lines before. It was written in C.
You mean this old thing:
#include <stdio.h>
#include <windows.h> 

int main(void)
{
  HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
  WORD wAttributes; 
  CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo ; 
  
  // save current text and backgroud colors
  GetConsoleScreenBufferInfo(hConsoleOutput, &lpConsoleScreenBufferInfo);
  wAttributes = lpConsoleScreenBufferInfo.wAttributes; 
  
  // set new text and background colors
  SetConsoleTextAttribute(hConsoleOutput, FOREGROUND_RED | FOREGROUND_INTENSITY);
  
  printf("Hello World! in colorful C\n");

  // restore origional text and background colors
  SetConsoleTextAttribute(hConsoleOutput, wAttributes);
  
  getchar();  // wait
  return 0;
}
Sure, you can use the Windows API functions in Python. Just get the Win32 extension package.
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote