473,544 Members | 2,231 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Coloring print lines

Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..

--SV

----Thanks in advance.
Jul 18 '05 #1
5 20827
Sami Viitanen enlightened us with:
Is there an easy way to make script print text with differents colors to
screen (shell)?
Sure, just use ANSI codes.
I mean a script that can for example print lines in red if some
error occurs in executing some information..


Example:

print "\033[31;1mError:\033[0m some message"

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Jul 18 '05 #2
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..

--SV

----Thanks in advance.

If you're using python at X, best advice I canv give is Text-widget at
Tkinter and RTFM (sorry couldn't resist temptation :) . Otherwise you
probably have to fiddle with curses-library (unix-only).

Best way to gather information of execution is to open log-file, code
couple of monkeys and let them crack system as much as possible. This is
only my opinion. Coders are blind to their mistakes even at testing.

Jul 18 '05 #3

"Risto Peränen" <no@more.spam.p lea.se> schrieb im Newsbeitrag
news:bi******** **@mordred.cc.j yu.fi...
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?
.... If you're using python at X, best advice I canv give is Text-widget at
Tkinter and RTFM (sorry couldn't resist temptation :) . Otherwise you
probably have to fiddle with curses-library (unix-only).


Some month's ago Adam Vandenberg released some alpha curses for Windows

http://flangy.com/dev/python/curses/

I worked with my Win2000 but is only a partial implementation. It has some
color support that migth suffice for the request of the OP.

Kindly
Michael P

Jul 18 '05 #4
| Is there an easy way to make script print text
| with different colors to screen (shell)?
| ...

Sami ...

I have a couple of small examples for printing
colorized strings via Ansi escape sequences
from Python under Windows ...

http://fastq.com/~sckitching/Python/ansi_strings.zip

--
Cousin Stanley
Human Being
Phoenix, Arizona
Jul 18 '05 #5
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..


IPython (http://ipython.scipy.org) supports coloring for its own purposes, and
comes with a module for this. You can simply import this module and use it for
your programs. Besides, you may like ipython itself ;)

Cheers,

f.
Jul 18 '05 #6

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

Similar topics

2
14673
by: Wow | last post by:
Do I have to replace all new lines with \n and document.write one line? Is there something like perl's print lines print << 'body'; body in javascripts?
5
5788
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting attachment to the email consistently does not display all of the lines it should in one of the GroupFooters. I am using the Print event in the report...
6
5515
by: Melissa | last post by:
Does anyone have a generic procedure for adding blank lines to reports like Sales details, PO details and/or Orders details. The procedure would need to count the number of line items, determine the remaining page to fill and print blank lines with the same number of fields as the line items. In addition, if there were a long list of line...
7
4748
lee123
by: lee123 | last post by:
hey ( killer42 ) hi there, im programing in vb 6 and i want to make lines on a invoice i created in vb6 but don't know how i would go about doing that.. i have everything layed out to print (codes) but no lines to separate the orders from one another, it doesn't look good the way it is i would like the lines in there as well lee123
4
1686
by: ramaswamynanda | last post by:
Hello, I have an application in Access where I have developed about 10 reports. These have been working for a while and produce data properly. I recently tried exporting the report, from the print preview mode to MSWord. The lines on the report do not print at all. The lines also do not print, if i take a report. I have checked the line...
12
1860
by: rajash | last post by:
Thanks to everyone on this forum for their helpful comments, now here is my solution to Exercise 1.17, pretty short and neat! // print lines longer than 80 chars char x; // allocate buffer void main() {
3
2662
by: lilly07 | last post by:
I am new to perl. I would like to open a file and print 2,6,10,14.. etc lines of that file content. How to do it? I amm able to open a file and print the contetnts as below: #!usr/bin/perl $data_file = "test.txt"; open(EXPORTFILE, $data_file) || die("Could not open file!"); print "Opened $data_file\n"; $counter = 0;...
3
1861
by: Anja Friedrich | last post by:
Hi all, I have another question. I have an array sorted like this: small_motif_a 1853 1863 small_motif_a 1970 1980 small_motif_a 1971 1981 small_motif_b 789 799 small_motif_b 882 892 small_motif_b 1181 1191 small_motif_b 1193 1203
15
2297
by: Chocolade | last post by:
public void logger_reader(string logger_reader) { string item = @"Last"; //*** Coloring all the text inside the richTextBox1 in Red ***\\ string ftext = File.ReadAllLines(logger_reader); for (int i = 0; i < ftext.Length; i++) { richTextBox1.SelectionColor =...
0
7438
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7374
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7632
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7783
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7392
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5309
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3422
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1850
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
996
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.