473,396 Members | 2,014 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,396 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 9142
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.