curses bkgd problem
Lee Harr
missive at frontiernet.net
Mon Mar 8 17:28:13 EST 2004
On 2004-03-08, Gandalf <gandalf at geochemsource.com> wrote:
>
> Hi Python Gurus!
>
> I read the documentation on the python curses module and I started a new
> application.
> So far I did this:
>
> 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()
>
> (writes "X11$terminal$emulator" in the top left corner in red and white).
> Please help me out with a few lines of code.
>
I must have had some trouble setting a background color also, as my
curses project has a module I called ColorFill.py ...
import curses
def colorFill(scr, pair):
if curses.has_colors():
scr.attron(curses.color_pair(pair))
(h, w) = scr.getmaxyx()
for y in range(h-1):
for x in range(w-1):
scr.move(y, x)
scr.addch(' ')
More information about the Python-list
mailing list