473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Colored text

Hello,
Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.

Aug 13 '07 #1
7 9139
On Aug 12, 10:05 pm, Rohan <vodela....@gmail.comwrote:
Hello,
Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.
Plain text files don't have color. You could output in html ...

Aug 13 '07 #2
On Aug 12, 10:01 pm, ianaré <ian...@gmail.comwrote:
On Aug 12, 10:05 pm, Rohan <vodela....@gmail.comwrote:
Hello,
Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.

Plain text files don't have color. You could output in html ...
Oh ok what about a csv file, I know its also a text file but I want
the color to be say blue in an excel sheet.

Aug 13 '07 #3

On Aug 12, 2007, at 7:05 PM, Rohan wrote:
Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.
You can use ANSI escape codes -- http://en.wikipedia.org/wiki/
ANSI_escape_code:

colorCodes = [
"\033[0mAll attributes off\033[0m",
"\033[1mBold\033[0m",
"\033[4mUnderline\033[0m",
"\033[5mBlink\033[0m",
"\033[8mHide\033[0m",
"\033[30mBlack\033[0m",
"\033[31mRed\033[0m",
"\033[32mGreen\033[0m",
"\033[33mYellow\033[0m",
"\033[34mBlue\033[0m",
"\033[35mMagenta\033[0m",
"\033[36mCyan\033[0m",
"\033[37mWhite\033[0m",
"\033[40m\033[37mBlack Background\033[0m",
"\033[41mRed Background\033[0m",
"\033[42mGreen Background\033[0m",
"\033[43mYellow Background\033[0m",
"\033[44mBlue Background\033[0m",
"\033[45mMagenta Background\033[0m",
"\033[46mCyan Background\033[0m",
"\033[47mWhite Background\033[0m"
]

for i in colorCodes:
print i

hth,
Michael
---
"I would rather use Java than Perl. And I'd rather be eaten by a
crocodile than use Java." — Trouser
Aug 13 '07 #4
On Aug 13, 1:50 am, Rohan <vodela....@gmail.comwrote:
On Aug 12, 10:01 pm, ianaré <ian...@gmail.comwrote:
On Aug 12, 10:05 pm, Rohan <vodela....@gmail.comwrote:
Hello,
Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.
Plain text files don't have color. You could output in html ...

Oh ok what about a csv file, I know its also a text file but I want
the color to be say blue in an excel sheet.
CSV is also pretty much plain text. No support for formatting.

You will need to write xls files. Personaly, I avoid proprietary file
formats like the plague, but this may be what you're looking for:

http://www.answermysearches.com/inde...in-python/122/

Aug 13 '07 #5
On 2007-08-13, Michael Bentley <mi*****@jedimindworks.comwrote:
>
On Aug 12, 2007, at 7:05 PM, Rohan wrote:
>Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.

You can use ANSI escape codes -- http://en.wikipedia.org/wiki/
ANSI_escape_code:
Unfortunately, most versions of Windows of the last 7 years
(2000, XP, probably Vista) don't support ANSI escape codes well
enough to work with Python.

--
Neil Cerutti
We have to play hard for the full 40 minutes. 48? Oh, that's right. --Mikki
Moore
Aug 13 '07 #6
On Aug 13, 10:37 am, Neil Cerutti <horp...@yahoo.comwrote:
On 2007-08-13, Michael Bentley <mich...@jedimindworks.comwrote:
On Aug 12, 2007, at 7:05 PM, Rohan wrote:
Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.
You can use ANSI escape codes --http://en.wikipedia.org/wiki/
ANSI_escape_code:

Unfortunately, most versions of Windows of the last 7 years
(2000, XP, probably Vista) don't support ANSI escape codes well
enough to work with Python.

--
Neil Cerutti
We have to play hard for the full 40 minutes. 48? Oh, that's right. --Mikki
Moore
Check out these recipes:
http://aspn.activestate.com/ASPN/Coo.../Recipe/475116
http://aspn.activestate.com/ASPN/Coo.../Recipe/496901

Aug 13 '07 #7
On 2007-08-13, Rohan <vo********@gmail.comwrote:
Hello,
Can some one tell me how do I get colored text. Say when I want to
write something in a text file , how do I get it colored.
The PyRTF module supports colored text, and RTF is portable
(mostly).

--
Grant Edwards grante Yow! What I want to find
at out is -- do parrots know
visi.com much about Astro-Turf?
Aug 15 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Susan G. Conger | last post by:
When I run the following HTML in IE, the First Name, Last Name and Email fields are colored and are 3d controls while the other fields are not. I don't know why this is. Can someone please tell...
0
by: Anonieko Ramos | last post by:
> I have a graphics images that I want to convert to > ASCII art. How do I do it? > Code: - Default.aspx.cs
7
by: ashkaan57 | last post by:
Hi, I was trying to display a small colored square using <table> tag. It worked fine on the screen but when I do print preview, the square shows up as white. I used both: <table width="15"...
0
by: lazaridis_com | last post by:
Colored Code Blocks Pudge generated documentation can contain colored code blocks, using the rst directive "..code-block:: Python" (an other languages supported by SilverCity). ...
1
by: abracad_1999 | last post by:
I have created a very simple form <form name="form1" method="post" action="" style="font-size:0.75em;"> e-mail <input type="text" name="textfield" size="15"> &nbsp;&nbsp;password <input...
2
lotus18
by: lotus18 | last post by:
Hello World Can anyone explain to me why i'm having a blue colored text in some of my files. My Local Disk (D:) also got it. I think I got this problem when I share my Local Disk (D:) over the...
1
by: pinkfloydhomer | last post by:
Can I write colored output with Debug.Write() to the Output Window? /David
6
by: CodeTilYaDrop | last post by:
I was wondering how some people have colored code and others do not. How do I get the colored code to show up in the forum? I think you can read it better. I was just curious so I can do it in the...
2
by: khacthuy | last post by:
I need to write a program with content: Colored plane graphs. Tell people what I know. I always code for the study. Thanks please send me mail: khacthuy.3k@gmail.com I come from VietNamese...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.