Markdown Format | JSON API | MCP Server Tool
Help on package curses: NAME curses - curses MODULE REFERENCE https://docs.python.org/3.10/library/curses.html The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above. DESCRIPTION The main package for curses support for Python. Normally used by importing the package, and perhaps a particular module inside it. import curses from curses import textpad curses.initscr() ... PACKAGE CONTENTS ascii has_key panel textpad FUNCTIONS baudrate() Return the output speed of the terminal in bits per second. beep() Emit a short attention sound. can_change_color() Return True if the programmer can change the colors displayed by the terminal. cbreak(flag=True, /) Enter cbreak mode. flag If false, the effect is the same as calling nocbreak(). In cbreak mode (sometimes called "rare" mode) normal tty line buffering is turned off and characters are available to be read one by one. However, unlike raw mode, special characters (interrupt, quit, suspend, and flow control) retain their effects on the tty driver and calling program. Calling first raw() then cbreak() leaves the terminal in cbreak mode. color_content(color_number, /) Return the red, green, and blue (RGB) components of the specified color. color_number The number of the color (0 - (COLORS-1)). A 3-tuple is returned, containing the R, G, B values for the given color, which will be between 0 (no component) and 1000 (maximum amount of component). color_pair(pair_number, /) Return the attribute value for displaying text in the specified color. pair_number The number of the color pair. This attribute value can be combined with A_STANDOUT, A_REVERSE, and the other A_* attributes. pair_number() is the counterpart to this function. curs_set(visibility, /) Set the cursor state. visibility 0 for invisible, 1 for normal visible, or 2 for very visible. If the terminal supports the visibility requested, the previous cursor state is returned; otherwise, an exception is raised. On many terminals, the "visible" mode is an underline cursor and the "very visible" mode is a block cursor. def_prog_mode() Save the current terminal mode as the "program" mode. The "program" mode is the mode when the running program is using curses. Subsequent calls to reset_prog_mode() will restore this mode. def_shell_mode() Save the current terminal mode as the "shell" mode. The "shell" mode is the mode when the running program is not using curses. Subsequent calls to reset_shell_mode() will restore this mode. delay_output(ms, /) Insert a pause in output. ms Duration in milliseconds. doupdate() Update the physical screen to match the virtual screen. echo(flag=True, /) Enter echo mode. flag If false, the effect is the same as calling noecho(). In echo mode, each character input is echoed to the screen as it is entered. endwin() De-initialize the library, and return terminal to normal status. erasechar() Return the user's current erase character. filter() flash() Flash the screen. That is, change it to reverse-video and then change it back in a short interval. flushinp() Flush all input buffers. This throws away any typeahead that has been typed by the user and has not yet been processed by the program. get_escdelay() Gets the curses ESCDELAY setting. Gets the number of milliseconds to wait after reading an escape character, to distinguish between an individual escape character entered on the keyboard from escape sequences sent by cursor and function keys. get_tabsize() Gets the curses TABSIZE setting. Gets the number of columns used by the curses library when converting a tab character to spaces as it adds the tab to a window. getmouse() Retrieve the queued mouse event. After getch() returns KEY_MOUSE to signal a mouse event, this function returns a 5-tuple (id, x, y, z, bstate). getsyx() Return the current coordinates of the virtual screen cursor. Return a (y, x) tuple. If leaveok is currently true, return (-1, -1). getwin(file, /) Read window related data stored in the file by an earlier putwin() call. The routine then creates and initializes a new window using that data, returning the new window object. halfdelay(tenths, /) Enter half-delay mode. tenths Maximal blocking delay in tenths of seconds (1 - 255). Use nocbreak() to leave half-delay mode. has_colors() Return True if the terminal can display colors; otherwise, return False. has_extended_color_support() Return True if the module supports extended colors; otherwise, return False. Extended color support allows more than 256 color-pairs for terminals that support more than 16 colors (e.g. xterm-256color). has_ic() Return True if the terminal has insert- and delete-character capabilities. has_il() Return True if the terminal has insert- and delete-line capabilities. has_key(key, /) Return True if the current terminal type recognizes a key with that value. key Key number. init_color(color_number, r, g, b, /) Change the definition of a color. color_number The number of the color to be changed (0 - (COLORS-1)). r Red component (0 - 1000). g Green component (0 - 1000). b Blue component (0 - 1000). When init_color() is used, all occurrences of that color on the screen immediately change to the new definition. This function is a no-op on most terminals; it is active only if can_change_color() returns true. init_pair(pair_number, fg, bg, /) Change the definition of a color-pair. pair_number The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)). fg Foreground color number (-1 - (COLORS-1)). bg Background color number (-1 - (COLORS-1)). If the color-pair was previously initialized, the screen is refreshed and all occurrences of that color-pair are changed to the new definition. initscr() intrflush(flag, /) is_term_resized(nlines, ncols, /) Return True if resize_term() would modify the window structure, False otherwise. nlines Height. ncols Width. isendwin() Return True if endwin() has been called. keyname(key, /) Return the name of specified key. key Key number. killchar() Return the user's current line kill character. longname() Return the terminfo long name field describing the current terminal. The maximum length of a verbose description is 128 characters. It is defined only after the call to initscr(). meta(yes, /) Enable/disable meta keys. If yes is True, allow 8-bit characters to be input. If yes is False, allow only 7-bit characters. mouseinterval(interval, /) Set and retrieve the maximum time between press and release in a click. interval Time in milliseconds. Set the maximum time that can elapse between press and release events in order for them to be recognized as a click, and return the previous interval value. mousemask(newmask, /) Set the mouse events to be reported, and return a tuple (availmask, oldmask). Return a tuple (availmask, oldmask). availmask indicates which of the specified mouse events can be reported; on complete failure it returns 0. oldmask is the previous value of the given window's mouse event mask. If this function is never called, no mouse events are ever reported. napms(ms, /) Sleep for specified time. ms Duration in milliseconds. newpad(nlines, ncols, /) Create and return a pointer to a new pad data structure. nlines Height. ncols Width. newwin(...) newwin(nlines, ncols, [begin_y=0, begin_x=0]) Return a new window. nlines Height. ncols Width. begin_y Top side y-coordinate. begin_x Left side x-coordinate. By default, the window will extend from the specified position to the lower right corner of the screen. nl(flag=True, /) Enter newline mode. flag If false, the effect is the same as calling nonl(). This mode translates the return key into newline on input, and translates newline into return and line-feed on output. Newline mode is initially on. nocbreak() Leave cbreak mode. Return to normal "cooked" mode with line buffering. noecho() Leave echo mode. Echoing of input characters is turned off. nonl() Leave newline mode. Disable translation of return into newline on input, and disable low-level translation of newline into newline/return on output. noqiflush() Disable queue flushing. When queue flushing is disabled, normal flush of input and output queues associated with the INTR, QUIT and SUSP characters will not be done. noraw() Leave raw mode. Return to normal "cooked" mode with line buffering. pair_content(pair_number, /) Return a tuple (fg, bg) containing the colors for the requested color pair. pair_number The number of the color pair (0 - (COLOR_PAIRS-1)). pair_number(attr, /) Return the number of the color-pair set by the specified attribute value. color_pair() is the counterpart to this function. putp(string, /) Emit the value of a specified terminfo capability for the current terminal. Note that the output of putp() always goes to standard output. qiflush(flag=True, /) Enable queue flushing. flag If false, the effect is the same as calling noqiflush(). If queue flushing is enabled, all output in the display driver queue will be flushed when the INTR, QUIT and SUSP characters are read. raw(flag=True, /) Enter raw mode. flag If false, the effect is the same as calling noraw(). In raw mode, normal line buffering and processing of interrupt, quit, suspend, and flow control keys are turned off; characters are presented to curses input functions one by one. reset_prog_mode() Restore the terminal to "program" mode, as previously saved by def_prog_mode(). reset_shell_mode() Restore the terminal to "shell" mode, as previously saved by def_shell_mode(). resetty() Restore terminal mode. resize_term(nlines, ncols, /) Backend function used by resizeterm(), performing most of the work. nlines Height. ncols Width. When resizing the windows, resize_term() blank-fills the areas that are extended. The calling application should fill in these areas with appropriate data. The resize_term() function attempts to resize all windows. However, due to the calling convention of pads, it is not possible to resize these without additional interaction with the application. resizeterm(nlines, ncols, /) Resize the standard and current windows to the specified dimensions. nlines Height. ncols Width. Adjusts other bookkeeping data used by the curses library that record the window dimensions (in particular the SIGWINCH handler). savetty() Save terminal mode. set_escdelay(ms, /) Sets the curses ESCDELAY setting. ms length of the delay in milliseconds. Sets the number of milliseconds to wait after reading an escape character, to distinguish between an individual escape character entered on the keyboard from escape sequences sent by cursor and function keys. set_tabsize(size, /) Sets the curses TABSIZE setting. size rendered cell width of a tab character. Sets the number of columns used by the curses library when converting a tab character to spaces as it adds the tab to a window. setsyx(y, x, /) Set the virtual screen cursor. y Y-coordinate. x X-coordinate. If y and x are both -1, then leaveok is set. setupterm(term=None, fd=-1) Initialize the terminal. term Terminal name. If omitted, the value of the TERM environment variable will be used. fd File descriptor to which any initialization sequences will be sent. If not supplied, the file descriptor for sys.stdout will be used. start_color() termattrs() Return a logical OR of all video attributes supported by the terminal. termname() Return the value of the environment variable TERM, truncated to 14 characters. tigetflag(capname, /) Return the value of the Boolean capability. capname The terminfo capability name. The value -1 is returned if capname is not a Boolean capability, or 0 if it is canceled or absent from the terminal description. tigetnum(capname, /) Return the value of the numeric capability. capname The terminfo capability name. The value -2 is returned if capname is not a numeric capability, or -1 if it is canceled or absent from the terminal description. tigetstr(capname, /) Return the value of the string capability. capname The terminfo capability name. None is returned if capname is not a string capability, or is canceled or absent from the terminal description. tparm(str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, /) Instantiate the specified byte string with the supplied parameters. str Parameterized byte string obtained from the terminfo database. typeahead(fd, /) Specify that the file descriptor fd be used for typeahead checking. fd File descriptor. If fd is -1, then no typeahead checking is done. unctrl(ch, /) Return a string which is a printable representation of the character ch. Control characters are displayed as a caret followed by the character, for example as ^C. Printing characters are left as they are. unget_wch(ch, /) Push ch so the next get_wch() will return it. ungetch(ch, /) Push ch so the next getch() will return it. ungetmouse(id, x, y, z, bstate, /) Push a KEY_MOUSE event onto the input queue. The following getmouse() will return the given state data. update_lines_cols() use_default_colors() Allow use of default values for colors on terminals supporting this feature. Use this to support transparency in your application. The default color is assigned to the color number -1. use_env(flag, /) Use environment variables LINES and COLUMNS. If used, this function should be called before initscr() or newterm() are called. When flag is False, the values of lines and columns specified in the terminfo database will be used, even if environment variables LINES and COLUMNS (used by default) are set, or if curses is running in a window (in which case default behavior would be to use the window size if LINES and COLUMNS are not set). wrapper(func, /, *args, **kwds) Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). DATA ALL_MOUSE_EVENTS = 268435455 A_ALTCHARSET = 4194304 A_ATTRIBUTES = 4294967040 A_BLINK = 524288 A_BOLD = 2097152 A_CHARTEXT = 255 A_COLOR = 65280 A_DIM = 1048576 A_HORIZONTAL = 33554432 A_INVIS = 8388608 A_ITALIC = 2147483648 A_LEFT = 67108864 A_LOW = 134217728 A_NORMAL = 0 A_PROTECT = 16777216 A_REVERSE = 262144 A_RIGHT = 268435456 A_STANDOUT = 65536 A_TOP = 536870912 A_UNDERLINE = 131072 A_VERTICAL = 1073741824 BUTTON1_CLICKED = 4 BUTTON1_DOUBLE_CLICKED = 8 BUTTON1_PRESSED = 2 BUTTON1_RELEASED = 1 BUTTON1_TRIPLE_CLICKED = 16 BUTTON2_CLICKED = 128 BUTTON2_DOUBLE_CLICKED = 256 BUTTON2_PRESSED = 64 BUTTON2_RELEASED = 32 BUTTON2_TRIPLE_CLICKED = 512 BUTTON3_CLICKED = 4096 BUTTON3_DOUBLE_CLICKED = 8192 BUTTON3_PRESSED = 2048 BUTTON3_RELEASED = 1024 BUTTON3_TRIPLE_CLICKED = 16384 BUTTON4_CLICKED = 131072 BUTTON4_DOUBLE_CLICKED = 262144 BUTTON4_PRESSED = 65536 BUTTON4_RELEASED = 32768 BUTTON4_TRIPLE_CLICKED = 524288 BUTTON5_CLICKED = 4194304 BUTTON5_DOUBLE_CLICKED = 8388608 BUTTON5_PRESSED = 2097152 BUTTON5_RELEASED = 1048576 BUTTON5_TRIPLE_CLICKED = 16777216 BUTTON_ALT = 134217728 BUTTON_CTRL = 33554432 BUTTON_SHIFT = 67108864 COLOR_BLACK = 0 COLOR_BLUE = 4 COLOR_CYAN = 6 COLOR_GREEN = 2 COLOR_MAGENTA = 5 COLOR_RED = 1 COLOR_WHITE = 7 COLOR_YELLOW = 3 ERR = -1 KEY_A1 = 348 KEY_A3 = 349 KEY_B2 = 350 KEY_BACKSPACE = 263 KEY_BEG = 354 KEY_BREAK = 257 KEY_BTAB = 353 KEY_C1 = 351 KEY_C3 = 352 KEY_CANCEL = 355 KEY_CATAB = 342 KEY_CLEAR = 333 KEY_CLOSE = 356 KEY_COMMAND = 357 KEY_COPY = 358 KEY_CREATE = 359 KEY_CTAB = 341 KEY_DC = 330 KEY_DL = 328 KEY_DOWN = 258 KEY_EIC = 332 KEY_END = 360 KEY_ENTER = 343 KEY_EOL = 335 KEY_EOS = 334 KEY_EXIT = 361 KEY_F0 = 264 KEY_F1 = 265 KEY_F10 = 274 KEY_F11 = 275 KEY_F12 = 276 KEY_F13 = 277 KEY_F14 = 278 KEY_F15 = 279 KEY_F16 = 280 KEY_F17 = 281 KEY_F18 = 282 KEY_F19 = 283 KEY_F2 = 266 KEY_F20 = 284 KEY_F21 = 285 KEY_F22 = 286 KEY_F23 = 287 KEY_F24 = 288 KEY_F25 = 289 KEY_F26 = 290 KEY_F27 = 291 KEY_F28 = 292 KEY_F29 = 293 KEY_F3 = 267 KEY_F30 = 294 KEY_F31 = 295 KEY_F32 = 296 KEY_F33 = 297 KEY_F34 = 298 KEY_F35 = 299 KEY_F36 = 300 KEY_F37 = 301 KEY_F38 = 302 KEY_F39 = 303 KEY_F4 = 268 KEY_F40 = 304 KEY_F41 = 305 KEY_F42 = 306 KEY_F43 = 307 KEY_F44 = 308 KEY_F45 = 309 KEY_F46 = 310 KEY_F47 = 311 KEY_F48 = 312 KEY_F49 = 313 KEY_F5 = 269 KEY_F50 = 314 KEY_F51 = 315 KEY_F52 = 316 KEY_F53 = 317 KEY_F54 = 318 KEY_F55 = 319 KEY_F56 = 320 KEY_F57 = 321 KEY_F58 = 322 KEY_F59 = 323 KEY_F6 = 270 KEY_F60 = 324 KEY_F61 = 325 KEY_F62 = 326 KEY_F63 = 327 KEY_F7 = 271 KEY_F8 = 272 KEY_F9 = 273 KEY_FIND = 362 KEY_HELP = 363 KEY_HOME = 262 KEY_IC = 331 KEY_IL = 329 KEY_LEFT = 260 KEY_LL = 347 KEY_MARK = 364 KEY_MAX = 511 KEY_MESSAGE = 365 KEY_MIN = 257 KEY_MOUSE = 409 KEY_MOVE = 366 KEY_NEXT = 367 KEY_NPAGE = 338 KEY_OPEN = 368 KEY_OPTIONS = 369 KEY_PPAGE = 339 KEY_PREVIOUS = 370 KEY_PRINT = 346 KEY_REDO = 371 KEY_REFERENCE = 372 KEY_REFRESH = 373 KEY_REPLACE = 374 KEY_RESET = 345 KEY_RESIZE = 410 KEY_RESTART = 375 KEY_RESUME = 376 KEY_RIGHT = 261 KEY_SAVE = 377 KEY_SBEG = 378 KEY_SCANCEL = 379 KEY_SCOMMAND = 380 KEY_SCOPY = 381 KEY_SCREATE = 382 KEY_SDC = 383 KEY_SDL = 384 KEY_SELECT = 385 KEY_SEND = 386 KEY_SEOL = 387 KEY_SEXIT = 388 KEY_SF = 336 KEY_SFIND = 389 KEY_SHELP = 390 KEY_SHOME = 391 KEY_SIC = 392 KEY_SLEFT = 393 KEY_SMESSAGE = 394 KEY_SMOVE = 395 KEY_SNEXT = 396 KEY_SOPTIONS = 397 KEY_SPREVIOUS = 398 KEY_SPRINT = 399 KEY_SR = 337 KEY_SREDO = 400 KEY_SREPLACE = 401 KEY_SRESET = 344 KEY_SRIGHT = 402 KEY_SRSUME = 403 KEY_SSAVE = 404 KEY_SSUSPEND = 405 KEY_STAB = 340 KEY_SUNDO = 406 KEY_SUSPEND = 407 KEY_UNDO = 408 KEY_UP = 259 OK = 0 REPORT_MOUSE_POSITION = 268435456 ncurses_version = curses.ncurses_version(major=6, minor=3, patch=20211... version = b'2.2' FILE /usr/lib/python3.10/curses/__init__.py
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:14 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)