Changeset 391 for python/trunk/Doc/howto/curses.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/howto/curses.rst
r2 r391 119 119 messed up when the application dies without restoring the terminal to its 120 120 previous state. In Python this commonly happens when your code is buggy and 121 raises an uncaught exception. Keys are no longer beechoed to the screen when121 raises an uncaught exception. Keys are no longer echoed to the screen when 122 122 you type them, for example, which makes using the shell difficult. 123 123 … … 145 145 window of a given size, returning the new window object. :: 146 146 147 begin_x = 20 148 height = 5 147 begin_x = 20; begin_y = 7 148 height = 5; width = 40 149 149 win = curses.newwin(height, width, begin_y, begin_x) 150 150 … … 185 185 for y in range(0, 100): 186 186 for x in range(0, 100): 187 try: pad.addch(y,x, ord('a') + (x*x+y*y) % 26 ) 188 except curses.error: pass 187 try: 188 pad.addch(y,x, ord('a') + (x*x+y*y) % 26) 189 except curses.error: 190 pass 189 191 190 192 # Displays a section of the pad in the middle of the screen 191 pad.refresh( 193 pad.refresh(0,0, 5,5, 20,75) 192 194 193 195 The :func:`refresh` call displays a section of the pad in the rectangle … … 272 274 attribute for each cell on the screen. 273 275 274 An attribute is a integer, each bit representing a different attribute. You can276 An attribute is an integer, each bit representing a different attribute. You can 275 277 try to display text with multiple attribute bits set, but curses doesn't 276 278 guarantee that all the possible combinations are available, or that they're all … … 301 303 stdscr.refresh() 302 304 303 The curses library also supports color on those terminals that provide it ,The305 The curses library also supports color on those terminals that provide it. The 304 306 most common such terminal is probably the Linux console, followed by color 305 307 xterms. … … 322 324 An example, which displays a line of text using color pair 1:: 323 325 324 stdscr.addstr( "Pretty text", curses.color_pair(1))326 stdscr.addstr("Pretty text", curses.color_pair(1)) 325 327 stdscr.refresh() 326 328 … … 344 346 with:: 345 347 346 stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1) 348 stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1)) 347 349 348 350 Very fancy terminals can change the definitions of the actual colors to a given … … 382 384 while 1: 383 385 c = stdscr.getch() 384 if c == ord('p'): PrintDocument() 385 elif c == ord('q'): break # Exit the while() 386 elif c == curses.KEY_HOME: x = y = 0 386 if c == ord('p'): 387 PrintDocument() 388 elif c == ord('q'): 389 break # Exit the while() 390 elif c == curses.KEY_HOME: 391 x = y = 0 387 392 388 393 The :mod:`curses.ascii` module supplies ASCII class membership functions that … … 434 439 435 440 The ncurses FAQ: http://invisible-island.net/ncurses/ncurses.faq.html 436
Note:
See TracChangeset
for help on using the changeset viewer.