curses bkgd problem

David M. Cooke cookedm+news at physics.mcmaster.ca
Tue Mar 9 23:22:08 CET 2004


At some point, Gandalf <gandalf at geochemsource.com> wrote:

> Gandalf wrote:
>
>> stdscr = curses.initscr() # Get standard screen
>> curses.start_color()      # Uses colors
>> stdscr.bkgd(' ',curses.COLOR_BLUE ) # Set background of the main window
>> curses.noecho()           # Do not echo input
>> curses.cbreak()           # CBreak mode: process keys immediately
>> (no ENTER)
>> stdscr.keypad(1)          # keypad mode: parse control sequences
>> stdscr.redrawwin()
>> stdscr.refresh()
>>
>> However, it is displaying $ characters in black instead of
>> displaying a blue background full of spaces.
>> This must be a problem with my bkgd call since this works fine:
>>
>> curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
>> stdscr.addstr(0, 0, curses.longname(), curses.color_pair(1) )
>> stdscr.refresh()
>>
> Now I'm doing this:
>
> def clrscr():
>     global stdscr
>     (maxy,maxx) = stdscr.getmaxyx()
>     line = ' ' * (maxx-1)
>     for row in range(maxy):
>         stdscr.addstr(row, 0, line, curses.color_pair(1) )
>
> which works fine except that the right side of the screen is still
> black.

Use a line of maxx blanks:
line = ' ' * maxx

> It is a very clumsy solution. Any ideas?

Nope ... puzzled. Looks like colour in curses is harder than it looks :-)

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list