In article <mailman.3163.1247670223.8015.python-l...@python.org>, Jean-Michel Pichavant <jeanmic...@sequans.com> wrote: >Nobody wrote: >> On Fri, 10 Jul 2009 09:23:54 +0000, garabik-news-2005-05 wrote: >> >> >>>>> I would like to learn a way of changing the colour of a particular >>>>> part of the output text. I've tried the following >>>>> >>>> On Unix operating systems this would be done through the curses interface: >>>> >>>> http://docs.python.org/library/curses.html >>>> >>> Or using ANSI colour codes: >>> >>> colours = { >>> 'none' : "", >>> 'default' : "\033[0m", >>> 'bold' : "\033[1m", >>> >> >> [snip] >> >> >>> # non-standard attributes, supported by some terminals >>> >> >> This comment should have appeared immediately after "none" ;) >> >> Hard-coding control/escape sequences is just lame. Use the curses modules >> to obtain the correct sequences for the terminal. >> >> >As the OP I'm really interested in doing so. I currently have all my >colors hard-coded. >Now It may be lame but as soon as I call curses.initscr(), it's just >messing up with my terminal, moreover I didn't figure out how to "print >'hello'" using curses color codes. >Anyone has an example ? I'm pretty sure it may fit in one line.
In general initscr() ought to work. It fails if it has no/a wrong idea of what your terminal is. In the same shell as you run run your program type set | grep -i term Now some entry should show up, e.g. TERM=xterm infocmp $TERM should fetch information about your terminal, from the same source as curses does. Possible problems are: - your operating system/configurations lies to curses about the terminal or your terminal is not specified at all - curses has not been properly installed and cannot find the database Groetjes Albert > >JM > > -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. alb...@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst -- http://mail.python.org/mailman/listinfo/python-list