{
    "mode": "pydoc",
    "parameter": "curses",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/curses/json",
    "generated": "2026-06-02T15:03:17Z",
    "sections": {
        "NAME": {
            "content": "curses - curses\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/curses.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The main package for curses support for Python.  Normally used by importing\nthe package, and perhaps a particular module inside it.\n\nimport curses\nfrom curses import textpad\ncurses.initscr()\n...\n",
            "subsections": []
        },
        "PACKAGE CONTENTS": {
            "content": "ascii\nhaskey\npanel\ntextpad\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "baudrate",
                    "content": "Return the output speed of the terminal in bits per second.\n"
                },
                {
                    "name": "beep",
                    "content": "Emit a short attention sound.\n"
                },
                {
                    "name": "can_change_color",
                    "content": "Return True if the programmer can change the colors displayed by the terminal.\n"
                },
                {
                    "name": "cbreak",
                    "content": "Enter cbreak mode.\n\nflag\nIf false, the effect is the same as calling nocbreak().\n\nIn cbreak mode (sometimes called \"rare\" mode) normal tty line buffering is\nturned off and characters are available to be read one by one.  However,\nunlike raw mode, special characters (interrupt, quit, suspend, and flow\ncontrol) retain their effects on the tty driver and calling program.\nCalling first raw() then cbreak() leaves the terminal in cbreak mode.\n"
                },
                {
                    "name": "color_content",
                    "content": "Return the red, green, and blue (RGB) components of the specified color.\n\ncolornumber\nThe number of the color (0 - (COLORS-1)).\n\nA 3-tuple is returned, containing the R, G, B values for the given color,\nwhich will be between 0 (no component) and 1000 (maximum amount of component).\n"
                },
                {
                    "name": "color_pair",
                    "content": "Return the attribute value for displaying text in the specified color.\n\npairnumber\nThe number of the color pair.\n\nThis attribute value can be combined with ASTANDOUT, AREVERSE, and the\nother A* attributes.  pairnumber() is the counterpart to this function.\n"
                },
                {
                    "name": "curs_set",
                    "content": "Set the cursor state.\n\nvisibility\n0 for invisible, 1 for normal visible, or 2 for very visible.\n\nIf the terminal supports the visibility requested, the previous cursor\nstate is returned; otherwise, an exception is raised.  On many terminals,\nthe \"visible\" mode is an underline cursor and the \"very visible\" mode is\na block cursor.\n"
                },
                {
                    "name": "def_prog_mode",
                    "content": "Save the current terminal mode as the \"program\" mode.\n\nThe \"program\" mode is the mode when the running program is using curses.\n\nSubsequent calls to resetprogmode() will restore this mode.\n"
                },
                {
                    "name": "def_shell_mode",
                    "content": "Save the current terminal mode as the \"shell\" mode.\n\nThe \"shell\" mode is the mode when the running program is not using curses.\n\nSubsequent calls to resetshellmode() will restore this mode.\n"
                },
                {
                    "name": "delay_output",
                    "content": "Insert a pause in output.\n\nms\nDuration in milliseconds.\n"
                },
                {
                    "name": "doupdate",
                    "content": "Update the physical screen to match the virtual screen.\n"
                },
                {
                    "name": "echo",
                    "content": "Enter echo mode.\n\nflag\nIf false, the effect is the same as calling noecho().\n\nIn echo mode, each character input is echoed to the screen as it is entered.\n"
                },
                {
                    "name": "endwin",
                    "content": "De-initialize the library, and return terminal to normal status.\n"
                },
                {
                    "name": "erasechar",
                    "content": "Return the user's current erase character.\n"
                },
                {
                    "name": "filter",
                    "content": ""
                },
                {
                    "name": "flash",
                    "content": "Flash the screen.\n\nThat is, change it to reverse-video and then change it back in a short interval.\n"
                },
                {
                    "name": "flushinp",
                    "content": "Flush all input buffers.\n\nThis throws away any typeahead that has been typed by the user and has not\nyet been processed by the program.\n"
                },
                {
                    "name": "get_escdelay",
                    "content": "Gets the curses ESCDELAY setting.\n\nGets the number of milliseconds to wait after reading an escape character,\nto distinguish between an individual escape character entered on the\nkeyboard from escape sequences sent by cursor and function keys.\n"
                },
                {
                    "name": "get_tabsize",
                    "content": "Gets the curses TABSIZE setting.\n\nGets the number of columns used by the curses library when converting a tab\ncharacter to spaces as it adds the tab to a window.\n"
                },
                {
                    "name": "getmouse",
                    "content": "Retrieve the queued mouse event.\n\nAfter getch() returns KEYMOUSE to signal a mouse event, this function\nreturns a 5-tuple (id, x, y, z, bstate).\n"
                },
                {
                    "name": "getsyx",
                    "content": "Return the current coordinates of the virtual screen cursor.\n\nReturn a (y, x) tuple.  If leaveok is currently true, return (-1, -1).\n"
                },
                {
                    "name": "getwin",
                    "content": "Read window related data stored in the file by an earlier putwin() call.\n\nThe routine then creates and initializes a new window using that data,\nreturning the new window object.\n"
                },
                {
                    "name": "halfdelay",
                    "content": "Enter half-delay mode.\n\ntenths\nMaximal blocking delay in tenths of seconds (1 - 255).\n\nUse nocbreak() to leave half-delay mode.\n"
                },
                {
                    "name": "has_colors",
                    "content": "Return True if the terminal can display colors; otherwise, return False.\n"
                },
                {
                    "name": "has_extended_color_support",
                    "content": "Return True if the module supports extended colors; otherwise, return False.\n\nExtended color support allows more than 256 color-pairs for terminals\nthat support more than 16 colors (e.g. xterm-256color).\n"
                },
                {
                    "name": "has_ic",
                    "content": "Return True if the terminal has insert- and delete-character capabilities.\n"
                },
                {
                    "name": "has_il",
                    "content": "Return True if the terminal has insert- and delete-line capabilities.\n"
                },
                {
                    "name": "has_key",
                    "content": "Return True if the current terminal type recognizes a key with that value.\n\nkey\nKey number.\n"
                },
                {
                    "name": "init_color",
                    "content": "Change the definition of a color.\n\ncolornumber\nThe number of the color to be changed (0 - (COLORS-1)).\nr\nRed component (0 - 1000).\ng\nGreen component (0 - 1000).\nb\nBlue component (0 - 1000).\n\nWhen initcolor() is used, all occurrences of that color on the screen\nimmediately change to the new definition.  This function is a no-op on\nmost terminals; it is active only if canchangecolor() returns true.\n"
                },
                {
                    "name": "init_pair",
                    "content": "Change the definition of a color-pair.\n\npairnumber\nThe number of the color-pair to be changed (1 - (COLORPAIRS-1)).\nfg\nForeground color number (-1 - (COLORS-1)).\nbg\nBackground color number (-1 - (COLORS-1)).\n\nIf the color-pair was previously initialized, the screen is refreshed and\nall occurrences of that color-pair are changed to the new definition.\n"
                },
                {
                    "name": "initscr",
                    "content": ""
                },
                {
                    "name": "intrflush",
                    "content": ""
                },
                {
                    "name": "is_term_resized",
                    "content": "Return True if resizeterm() would modify the window structure, False otherwise.\n\nnlines\nHeight.\nncols\nWidth.\n"
                },
                {
                    "name": "isendwin",
                    "content": "Return True if endwin() has been called.\n"
                },
                {
                    "name": "keyname",
                    "content": "Return the name of specified key.\n\nkey\nKey number.\n"
                },
                {
                    "name": "killchar",
                    "content": "Return the user's current line kill character.\n"
                },
                {
                    "name": "longname",
                    "content": "Return the terminfo long name field describing the current terminal.\n\nThe maximum length of a verbose description is 128 characters.  It is defined\nonly after the call to initscr().\n"
                },
                {
                    "name": "meta",
                    "content": "Enable/disable meta keys.\n\nIf yes is True, allow 8-bit characters to be input.  If yes is False,\nallow only 7-bit characters.\n"
                },
                {
                    "name": "mouseinterval",
                    "content": "Set and retrieve the maximum time between press and release in a click.\n\ninterval\nTime in milliseconds.\n\nSet the maximum time that can elapse between press and release events in\norder for them to be recognized as a click, and return the previous interval\nvalue.\n"
                },
                {
                    "name": "mousemask",
                    "content": "Set the mouse events to be reported, and return a tuple (availmask, oldmask).\n\nReturn a tuple (availmask, oldmask).  availmask indicates which of the\nspecified mouse events can be reported; on complete failure it returns 0.\noldmask is the previous value of the given window's mouse event mask.\nIf this function is never called, no mouse events are ever reported.\n"
                },
                {
                    "name": "napms",
                    "content": "Sleep for specified time.\n\nms\nDuration in milliseconds.\n"
                },
                {
                    "name": "newpad",
                    "content": "Create and return a pointer to a new pad data structure.\n\nnlines\nHeight.\nncols\nWidth.\n"
                },
                {
                    "name": "newwin",
                    "content": "newwin(nlines, ncols, [beginy=0, beginx=0])\nReturn a new window.\n\nnlines\nHeight.\nncols\nWidth.\nbeginy\nTop side y-coordinate.\nbeginx\nLeft side x-coordinate.\n\nBy default, the window will extend from the specified position to the lower\nright corner of the screen.\n"
                },
                {
                    "name": "nl",
                    "content": "Enter newline mode.\n\nflag\nIf false, the effect is the same as calling nonl().\n\nThis mode translates the return key into newline on input, and translates\nnewline into return and line-feed on output.  Newline mode is initially on.\n"
                },
                {
                    "name": "nocbreak",
                    "content": "Leave cbreak mode.\n\nReturn to normal \"cooked\" mode with line buffering.\n"
                },
                {
                    "name": "noecho",
                    "content": "Leave echo mode.\n\nEchoing of input characters is turned off.\n"
                },
                {
                    "name": "nonl",
                    "content": "Leave newline mode.\n\nDisable translation of return into newline on input, and disable low-level\ntranslation of newline into newline/return on output.\n"
                },
                {
                    "name": "noqiflush",
                    "content": "Disable queue flushing.\n\nWhen queue flushing is disabled, normal flush of input and output queues\nassociated with the INTR, QUIT and SUSP characters will not be done.\n"
                },
                {
                    "name": "noraw",
                    "content": "Leave raw mode.\n\nReturn to normal \"cooked\" mode with line buffering.\n"
                },
                {
                    "name": "pair_content",
                    "content": "Return a tuple (fg, bg) containing the colors for the requested color pair.\n\npairnumber\nThe number of the color pair (0 - (COLORPAIRS-1)).\n"
                },
                {
                    "name": "pair_number",
                    "content": "Return the number of the color-pair set by the specified attribute value.\n\ncolorpair() is the counterpart to this function.\n"
                },
                {
                    "name": "putp",
                    "content": "Emit the value of a specified terminfo capability for the current terminal.\n\nNote that the output of putp() always goes to standard output.\n"
                },
                {
                    "name": "qiflush",
                    "content": "Enable queue flushing.\n\nflag\nIf false, the effect is the same as calling noqiflush().\n\nIf queue flushing is enabled, all output in the display driver queue\nwill be flushed when the INTR, QUIT and SUSP characters are read.\n"
                },
                {
                    "name": "raw",
                    "content": "Enter raw mode.\n\nflag\nIf false, the effect is the same as calling noraw().\n\nIn raw mode, normal line buffering and processing of interrupt, quit,\nsuspend, and flow control keys are turned off; characters are presented to\ncurses input functions one by one.\n"
                },
                {
                    "name": "reset_prog_mode",
                    "content": "Restore the terminal to \"program\" mode, as previously saved by defprogmode().\n"
                },
                {
                    "name": "reset_shell_mode",
                    "content": "Restore the terminal to \"shell\" mode, as previously saved by defshellmode().\n"
                },
                {
                    "name": "resetty",
                    "content": "Restore terminal mode.\n"
                },
                {
                    "name": "resize_term",
                    "content": "Backend function used by resizeterm(), performing most of the work.\n\nnlines\nHeight.\nncols\nWidth.\n\nWhen resizing the windows, resizeterm() blank-fills the areas that are\nextended.  The calling application should fill in these areas with appropriate\ndata.  The resizeterm() function attempts to resize all windows.  However,\ndue to the calling convention of pads, it is not possible to resize these\nwithout additional interaction with the application.\n"
                },
                {
                    "name": "resizeterm",
                    "content": "Resize the standard and current windows to the specified dimensions.\n\nnlines\nHeight.\nncols\nWidth.\n\nAdjusts other bookkeeping data used by the curses library that record the\nwindow dimensions (in particular the SIGWINCH handler).\n"
                },
                {
                    "name": "savetty",
                    "content": "Save terminal mode.\n"
                },
                {
                    "name": "set_escdelay",
                    "content": "Sets the curses ESCDELAY setting.\n\nms\nlength of the delay in milliseconds.\n\nSets the number of milliseconds to wait after reading an escape character,\nto distinguish between an individual escape character entered on the\nkeyboard from escape sequences sent by cursor and function keys.\n"
                },
                {
                    "name": "set_tabsize",
                    "content": "Sets the curses TABSIZE setting.\n\nsize\nrendered cell width of a tab character.\n\nSets the number of columns used by the curses library when converting a tab\ncharacter to spaces as it adds the tab to a window.\n"
                },
                {
                    "name": "setsyx",
                    "content": "Set the virtual screen cursor.\n\ny\nY-coordinate.\nx\nX-coordinate.\n\nIf y and x are both -1, then leaveok is set.\n"
                },
                {
                    "name": "setupterm",
                    "content": "Initialize the terminal.\n\nterm\nTerminal name.\nIf omitted, the value of the TERM environment variable will be used.\nfd\nFile descriptor to which any initialization sequences will be sent.\nIf not supplied, the file descriptor for sys.stdout will be used.\n"
                },
                {
                    "name": "start_color",
                    "content": ""
                },
                {
                    "name": "termattrs",
                    "content": "Return a logical OR of all video attributes supported by the terminal.\n"
                },
                {
                    "name": "termname",
                    "content": "Return the value of the environment variable TERM, truncated to 14 characters.\n"
                },
                {
                    "name": "tigetflag",
                    "content": "Return the value of the Boolean capability.\n\ncapname\nThe terminfo capability name.\n\nThe value -1 is returned if capname is not a Boolean capability, or 0 if\nit is canceled or absent from the terminal description.\n"
                },
                {
                    "name": "tigetnum",
                    "content": "Return the value of the numeric capability.\n\ncapname\nThe terminfo capability name.\n\nThe value -2 is returned if capname is not a numeric capability, or -1 if\nit is canceled or absent from the terminal description.\n"
                },
                {
                    "name": "tigetstr",
                    "content": "Return the value of the string capability.\n\ncapname\nThe terminfo capability name.\n\nNone is returned if capname is not a string capability, or is canceled or\nabsent from the terminal description.\n"
                },
                {
                    "name": "tparm",
                    "content": "Instantiate the specified byte string with the supplied parameters.\n\nstr\nParameterized byte string obtained from the terminfo database.\n"
                },
                {
                    "name": "typeahead",
                    "content": "Specify that the file descriptor fd be used for typeahead checking.\n\nfd\nFile descriptor.\n\nIf fd is -1, then no typeahead checking is done.\n"
                },
                {
                    "name": "unctrl",
                    "content": "Return a string which is a printable representation of the character ch.\n\nControl characters are displayed as a caret followed by the character,\nfor example as ^C.  Printing characters are left as they are.\n"
                },
                {
                    "name": "unget_wch",
                    "content": "Push ch so the next getwch() will return it.\n"
                },
                {
                    "name": "ungetch",
                    "content": "Push ch so the next getch() will return it.\n"
                },
                {
                    "name": "ungetmouse",
                    "content": "Push a KEYMOUSE event onto the input queue.\n\nThe following getmouse() will return the given state data.\n"
                },
                {
                    "name": "update_lines_cols",
                    "content": ""
                },
                {
                    "name": "use_default_colors",
                    "content": "Allow use of default values for colors on terminals supporting this feature.\n\nUse this to support transparency in your application.  The default color\nis assigned to the color number -1.\n"
                },
                {
                    "name": "use_env",
                    "content": "Use environment variables LINES and COLUMNS.\n\nIf used, this function should be called before initscr() or newterm() are\ncalled.\n\nWhen flag is False, the values of lines and columns specified in the terminfo\ndatabase will be used, even if environment variables LINES and COLUMNS (used\nby default) are set, or if curses is running in a window (in which case\ndefault behavior would be to use the window size if LINES and COLUMNS are\nnot set).\n"
                },
                {
                    "name": "wrapper",
                    "content": "Wrapper function that initializes curses and calls another function,\nrestoring normal keyboard/screen behavior on error.\nThe callable object 'func' is then passed the main window 'stdscr'\nas its first argument, followed by any other arguments passed to\nwrapper().\n"
                }
            ]
        },
        "DATA": {
            "content": "ALLMOUSEEVENTS = 268435455\nAALTCHARSET = 4194304\nAATTRIBUTES = 4294967040\nABLINK = 524288\nABOLD = 2097152\nACHARTEXT = 255\nACOLOR = 65280\nADIM = 1048576\nAHORIZONTAL = 33554432\nAINVIS = 8388608\nAITALIC = 2147483648\nALEFT = 67108864\nALOW = 134217728\nANORMAL = 0\nAPROTECT = 16777216\nAREVERSE = 262144\nARIGHT = 268435456\nASTANDOUT = 65536\nATOP = 536870912\nAUNDERLINE = 131072\nAVERTICAL = 1073741824\nBUTTON1CLICKED = 4\nBUTTON1DOUBLECLICKED = 8\nBUTTON1PRESSED = 2\nBUTTON1RELEASED = 1\nBUTTON1TRIPLECLICKED = 16\nBUTTON2CLICKED = 128\nBUTTON2DOUBLECLICKED = 256\nBUTTON2PRESSED = 64\nBUTTON2RELEASED = 32\nBUTTON2TRIPLECLICKED = 512\nBUTTON3CLICKED = 4096\nBUTTON3DOUBLECLICKED = 8192\nBUTTON3PRESSED = 2048\nBUTTON3RELEASED = 1024\nBUTTON3TRIPLECLICKED = 16384\nBUTTON4CLICKED = 131072\nBUTTON4DOUBLECLICKED = 262144\nBUTTON4PRESSED = 65536\nBUTTON4RELEASED = 32768\nBUTTON4TRIPLECLICKED = 524288\nBUTTON5CLICKED = 4194304\nBUTTON5DOUBLECLICKED = 8388608\nBUTTON5PRESSED = 2097152\nBUTTON5RELEASED = 1048576\nBUTTON5TRIPLECLICKED = 16777216\nBUTTONALT = 134217728\nBUTTONCTRL = 33554432\nBUTTONSHIFT = 67108864\nCOLORBLACK = 0\nCOLORBLUE = 4\nCOLORCYAN = 6\nCOLORGREEN = 2\nCOLORMAGENTA = 5\nCOLORRED = 1\nCOLORWHITE = 7\nCOLORYELLOW = 3\nERR = -1\nKEYA1 = 348\nKEYA3 = 349\nKEYB2 = 350\nKEYBACKSPACE = 263\nKEYBEG = 354\nKEYBREAK = 257\nKEYBTAB = 353\nKEYC1 = 351\nKEYC3 = 352\nKEYCANCEL = 355\nKEYCATAB = 342\nKEYCLEAR = 333\nKEYCLOSE = 356\nKEYCOMMAND = 357\nKEYCOPY = 358\nKEYCREATE = 359\nKEYCTAB = 341\nKEYDC = 330\nKEYDL = 328\nKEYDOWN = 258\nKEYEIC = 332\nKEYEND = 360\nKEYENTER = 343\nKEYEOL = 335\nKEYEOS = 334\nKEYEXIT = 361\nKEYF0 = 264\nKEYF1 = 265\nKEYF10 = 274\nKEYF11 = 275\nKEYF12 = 276\nKEYF13 = 277\nKEYF14 = 278\nKEYF15 = 279\nKEYF16 = 280\nKEYF17 = 281\nKEYF18 = 282\nKEYF19 = 283\nKEYF2 = 266\nKEYF20 = 284\nKEYF21 = 285\nKEYF22 = 286\nKEYF23 = 287\nKEYF24 = 288\nKEYF25 = 289\nKEYF26 = 290\nKEYF27 = 291\nKEYF28 = 292\nKEYF29 = 293\nKEYF3 = 267\nKEYF30 = 294\nKEYF31 = 295\nKEYF32 = 296\nKEYF33 = 297\nKEYF34 = 298\nKEYF35 = 299\nKEYF36 = 300\nKEYF37 = 301\nKEYF38 = 302\nKEYF39 = 303\nKEYF4 = 268\nKEYF40 = 304\nKEYF41 = 305\nKEYF42 = 306\nKEYF43 = 307\nKEYF44 = 308\nKEYF45 = 309\nKEYF46 = 310\nKEYF47 = 311\nKEYF48 = 312\nKEYF49 = 313\nKEYF5 = 269\nKEYF50 = 314\nKEYF51 = 315\nKEYF52 = 316\nKEYF53 = 317\nKEYF54 = 318\nKEYF55 = 319\nKEYF56 = 320\nKEYF57 = 321\nKEYF58 = 322\nKEYF59 = 323\nKEYF6 = 270\nKEYF60 = 324\nKEYF61 = 325\nKEYF62 = 326\nKEYF63 = 327\nKEYF7 = 271\nKEYF8 = 272\nKEYF9 = 273\nKEYFIND = 362\nKEYHELP = 363\nKEYHOME = 262\nKEYIC = 331\nKEYIL = 329\nKEYLEFT = 260\nKEYLL = 347\nKEYMARK = 364\nKEYMAX = 511\nKEYMESSAGE = 365\nKEYMIN = 257\nKEYMOUSE = 409\nKEYMOVE = 366\nKEYNEXT = 367\nKEYNPAGE = 338\nKEYOPEN = 368\nKEYOPTIONS = 369\nKEYPPAGE = 339\nKEYPREVIOUS = 370\nKEYPRINT = 346\nKEYREDO = 371\nKEYREFERENCE = 372\nKEYREFRESH = 373\nKEYREPLACE = 374\nKEYRESET = 345\nKEYRESIZE = 410\nKEYRESTART = 375\nKEYRESUME = 376\nKEYRIGHT = 261\nKEYSAVE = 377\nKEYSBEG = 378\nKEYSCANCEL = 379\nKEYSCOMMAND = 380\nKEYSCOPY = 381\nKEYSCREATE = 382\nKEYSDC = 383\nKEYSDL = 384\nKEYSELECT = 385\nKEYSEND = 386\nKEYSEOL = 387\nKEYSEXIT = 388\nKEYSF = 336\nKEYSFIND = 389\nKEYSHELP = 390\nKEYSHOME = 391\nKEYSIC = 392\nKEYSLEFT = 393\nKEYSMESSAGE = 394\nKEYSMOVE = 395\nKEYSNEXT = 396\nKEYSOPTIONS = 397\nKEYSPREVIOUS = 398\nKEYSPRINT = 399\nKEYSR = 337\nKEYSREDO = 400\nKEYSREPLACE = 401\nKEYSRESET = 344\nKEYSRIGHT = 402\nKEYSRSUME = 403\nKEYSSAVE = 404\nKEYSSUSPEND = 405\nKEYSTAB = 340\nKEYSUNDO = 406\nKEYSUSPEND = 407\nKEYUNDO = 408\nKEYUP = 259\nOK = 0\nREPORTMOUSEPOSITION = 268435456\nncursesversion = curses.ncursesversion(major=6, minor=3, patch=20211...\nversion = b'2.2'\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/curses/init.py\n\n",
            "subsections": []
        }
    },
    "summary": "curses - curses",
    "flags": [],
    "examples": [],
    "see_also": []
}