Re: [Tutor] linux terminal coloring in python
Robert Jackson wrote: > I'm trying to get some pretty colored output for a Linux console / terminal > window. Google searches only reveal the curses module to colorize output. > > Is there a simpler way? Curses seems to be FAR too powerful for what it is I > want to do (simply to colorize a few 'print' outputs to the console). > I stumbled across a recipe for a portable terminal colouring scheme here http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116 You need to use the curses module but don't need to put the terminal into raw mode etc. Maybe it will suit your needs. Peace -- ~noufal ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] linux terminal coloring in python
Hello, I actually wanted/looked for colored output in the CLI for quite a while myself, and finally found the solution! The magic?: "echo -e". The syntax is a little odd to use it, and I don't think I can explain it very succinctly. It may be best to see an example of it in action. I wrote a bash script to summarize files, and I used the "echo -e" syntax to color the output. Actual code: http://launchpod.homelinux.com:81/trac/code/browser/userextensions/summarizer.sh Details here, with screenshots: http://assistedsilicon.blogspot.com/2007/04/summary-execution.html Good luck! -Sam _ - Original Message From: Tiago Saboga <[EMAIL PROTECTED]> To: tutor@python.org Sent: Saturday, September 29, 2007 6:11:35 PM Subject: Re: [Tutor] linux terminal coloring in python On Sat, Sep 29, 2007 at 08:32:37AM -0700, Robert Jackson wrote: > I'm trying to get some pretty colored output for a Linux console / terminal window. Google searches only reveal the curses module to colorize output. > Is there a simpler way? Curses seems to be FAR too powerful for what it is I want to do (simply to colorize a few 'print' outputs to the console). I have looked for that last week and the best I could find was ColorANSI module, distributed with ipython (in a debian system, it's /usr/share/python-support/ipython/IPython/ColorANSI.py). I just bookmarked it, and don't know how to make it work. But it seems quite simple. Tiago. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] linux terminal coloring in python
"Robert Jackson" <[EMAIL PROTECTED]> wrote > I'm trying to get some pretty colored output for a Linux console > / terminal window. Google searches only reveal the curses module > to colorize output. curses means it will work for any console supporting color and curses. > Is there a simpler way? Curses seems to be FAR too powerful If you know for sure what terminal you are using then you can send control codes to the screen directly. But since color terninals are far from standard you will need to find out what kind of terminal you are using (eg Dec VT340 supports color as do various Tectronics and Wyse terminals). On Linux you are probably using a terminal emulator running in an xterm or some other window interface. Xterm uses the terminal settings you tell it to use in the X resources. But some more modern consoles have their own codes so you need to look them up. In short if you know the control codes used to change color then it's easy to print them out. Something like: # These codes are just made up, you need the real ones! YELLOW = 0x23 BLUE = 0x4A RED = 0xB2 print YELLOW, 'This is yellow', RED, 'and this is red' But that will produce something completely different in another console type. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] linux terminal coloring in python
On Sat, Sep 29, 2007 at 08:32:37AM -0700, Robert Jackson wrote: > I'm trying to get some pretty colored output for a Linux console / terminal window. Google searches only reveal the curses module to colorize output. > Is there a simpler way? Curses seems to be FAR too powerful for what it is I want to do (simply to colorize a few 'print' outputs to the console). I have looked for that last week and the best I could find was ColorANSI module, distributed with ipython (in a debian system, it's /usr/share/python-support/ipython/IPython/ColorANSI.py). I just bookmarked it, and don't know how to make it work. But it seems quite simple. Tiago. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] linux terminal coloring in python
I'm trying to get some pretty colored output for a Linux console / terminal window. Google searches only reveal the curses module to colorize output. Is there a simpler way? Curses seems to be FAR too powerful for what it is I want to do (simply to colorize a few 'print' outputs to the console). Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. http://mobile.yahoo.com/go?refer=1GNXIC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor