obtain the y and x sizes. Legal coordinates will then extend from$_{(0,0)}$ to$_{(curses.LINES - 1, curses.}$ COLS - 1) . When you call a method to display or erase text, the effect doesn’t immediately show up on the display. Instead you must call the refresh() method of window objects to update the screen. This is because curses was originally written with slow 300-baud terminal connections in mind; with these terminals, minimizing the time required to redraw the screen was very important. Instead curses accumulates changes to the screen and displays them in the most efficient manner when you call refresh() . For example, if your program displays some text in a window and then clears the window, there’s no need to send the original text because they’re never visible. In practice, explicitly telling curses to redraw a window doesn’t really complicate programming with curses much. Most programs go into a flurry of activity, and then pause waiting for a keypress or some other action on the part of the user. All you have to do is to be sure that the screen has been redrawn before pausing to wait for user input, by first calling stdscr.refresh() or the refresh() method of some other relevant window. A pad is a special case of a window; it can be larger than the actual display screen, and only a portion of the pad displayed at a time. Creating a pad requires the pad’s height and width, while refreshing a pad requires giving the coordinates of the on-screen area where a subsection of the pad will be displayed. The$_{refresh()}$ call displays a section of the pad in the rectangle extending from coordinate (5,5) to coordinate (20,75) on the screen; the upper left corner of the displayed section is coordinate (0,0) on the pad. Beyond that difference, pads are exactly like ordinary windows and support the same methods. If you have multiple windows and pads on screen there is a more efficient way to update the screen and prevent annoying screen flicker as each part of the screen gets updated.$_{refresh()}$ actually does two things: Instead you can call noutrefresh() on a number of windows to update the data structure, and then call doupdate() to update the screen. 1) Calls the$_{noutrefresh()}$ method of each window to update an underlying data structure representing the desired state of the screen. 2) Calls the function$_{doupdate()}$ function to change the physical screen to match the desired state recorded in the data structure. pad =curses.newpad( 100 ,100 ) # These loops fill the pad with letters; addch() is # explained in the next section for y in range(0,99 ): for x in range(0,99 ): pad.addch(y,x, ord('a')+(x*x+y*y)%26 ) # Displays a section of the pad in the middle of the screen. # (0,0) : coordinate of upper-left corner of pad area to display. # (5,5) : coordinate of upper-left corner of window area to be filled # with pad content. # (20, 75) : coordinate of lower-right corner of window area to be # : filled with pad content. pad.refresh( 0,0,5,5,20 ,75 ) 4