Change Font Color (in script mode)

A forum for general discussion of the Python programming language.

Change Font Color (in script mode)

Postby tiny » Thu Oct 17, 2013 6:29 pm

Hi,
How do i change the font color in script mode? I see import.os os.system("color 15") for the shell....but this doesn't work for script mode.

Any ideas?
tiny
 
Posts: 9
Joined: Tue Oct 08, 2013 8:55 am

Re: Change Font Color (in script mode)

Postby stranac » Thu Oct 17, 2013 7:14 pm

I have no idea what you're talking about...
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 897
Joined: Thu Feb 07, 2013 3:42 pm

Re: Change Font Color (in script mode)

Postby tiny » Thu Oct 17, 2013 7:18 pm

lol..
Changing the colour of the text in Python...? any ideas how to? (I use Script mode - i've seen others post on how to do it for interpretted mode...but that doesn't seem to work for me) I use Python 3.3.2 IDLE
tiny
tiny
 
Posts: 9
Joined: Tue Oct 08, 2013 8:55 am

Re: Change Font Color (in script mode)

Postby dboxall123 » Thu Oct 17, 2013 7:25 pm

Script mode? Do you mean you are using an IDE or a text editor as opposed to using the shell?
dboxall123
 
Posts: 108
Joined: Fri Jul 12, 2013 5:28 pm

Re: Change Font Color (in script mode)

Postby tiny » Thu Oct 17, 2013 7:39 pm

Using an IDE.
tiny
 
Posts: 9
Joined: Tue Oct 08, 2013 8:55 am

Re: Change Font Color (in script mode)

Postby dboxall123 » Thu Oct 17, 2013 7:43 pm

In which case you won't need to use any code to change the colours, you change font colours through the options at the top of the window. For example, if you are using IDLE you just select Options/Configure Idle/Highlighting. You can change the font colours from there.
dboxall123
 
Posts: 108
Joined: Fri Jul 12, 2013 5:28 pm

Re: Change Font Color (in script mode)

Postby tiny » Thu Oct 17, 2013 7:46 pm

I would like to output...
print('Hello World') in green

then output...
print('I love Python') in red.

ie. python command for changing the output font colour?
tiny
 
Posts: 9
Joined: Tue Oct 08, 2013 8:55 am

Re: Change Font Color (in script mode)

Postby stranac » Thu Oct 17, 2013 8:46 pm

There is no such function built-in.

It is possible to do, but how depends on your environment.
One option would be using ANSI escape sequences(if your environment supports them), or using an external library, such as colorama

Also: don't ask the same question in multiple threads.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 897
Joined: Thu Feb 07, 2013 3:42 pm


Return to General Discussions

Who is online

Users browsing this forum: daytripper1989 and 1 guest