Name
wrapper
Synopsis
wrapper(func
,*args
)
Performs curses
initialization, calls
func
(stdscr,*
args
)
,
performs curses
finalization (setting the terminal
back to normal behavior), and finally returns
func
’s result. The first
argument that wrapper
passes to
func
is stdscr
, an
object of type curses.Window
that represents the
whole terminal screen. wrapper
ensures that the
terminal is set back to normal behavior, whether
func
terminates normally or by propagating
an exception.
func
should be a function that performs
all the tasks in your program that may need curses
functionality. In other words, func
normally contains (or more commonly calls, directly or indirectly,
functions containing) all of your program’s
functionality, save perhaps for some non-interactive initialization
and/or finalization tasks.
curses
models text and background colors of
characters as character attributes. Colors available on the terminal
are numbered from 0
to
curses.COLORS
. Function
color_content
takes a color number
n
as its argument, and returns a tuple
(
r
,g
,b
)
of integers between 0
and 1000
giving the amount of each primary color in
n
. Function color_pair
takes a color number n
as its argument,
and returns an attribute code that you can pass to various methods of
a curses.Window
object in order to display text in
that color.
curses
lets you create multiple instances of type
curses.Window
, each corresponding to a rectangle
on the screen. You can also create exotic variants, such as instances
of Panel
, which ...
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.