Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Use curses, don't swear by Sean Zicari

PyCon 2013
March 18, 2013

Use curses, don't swear by Sean Zicari

PyCon 2013

March 18, 2013
Tweet

More Decks by PyCon 2013

Other Decks in Technology

Transcript

  1. . Web Developer . Love all things low level .

    Love computer history whoami
  2. . Web Developer . Love all things low level .

    Love computer history whoami
  3. . Web Developer . Love all things low level .

    Love computer history whoami
  4. . First VT ~1969 . Basic line/screen control . ASCII

    character set . ~300 baud (characters/second) video terminals!
  5. . First VT ~1970 . Basic line control . ASCII

    character set . ~300 baud (characters/second) video terminals! VT-100
  6. . Kernel handled data transfer . Terminal handled display (cursor,

    color, line handling...) . Terminal control through escape sequences talking to a terminal
  7. . Vendor-specific escape sequences . ECMA-48 adopted in 1976 .

    termcap released in 1978 (TERMinal CAPability) standards? nope. Esc[20h Set new line mode LMN Esc[?1h Set cursor key to application DECCKM none Set ANSI (versus VT52) DECANM Esc[?3h Set number of columns to 132 DECCOLM Esc[?4h Set smooth scrolling DECSCLM Esc[?5h Set reverse video on screen DECSCNM Esc[?6h Set origin to relative DECOM Esc[?7h Set auto-wrap mode DECAWM Esc[?8h Set auto-repeat mode DECARM Esc[?9h Set interlacing mode DECINLM
  8. . Vendor-specific escape sequences . ECMA-48 adopted in 1976 .

    termcap released in 1978 (TERMinal CAPability) standards? nope.
  9. . Vendor-specific escape sequences . ECMA-48 adopted in 1976 .

    termcap released in 1978 (TERMinal CAPability) standards? nope.
  10. introducing (n)curses . Developed for BSD . Code borrowed from

    vi . Originally used termcap . Unix System III / V . Gained additional features . Curses became pcurses . pcurses became n(ew)curses
  11. why (n)curses? . Plethora of terminals . Plethora of escape

    sequence variations . Portable . Convenient abstractions . Standardized API
  12. (n)curses philosophy . Tools provided... . ...but you're on your

    own . One primary object: stdscr . Full cursor/screen control . Forms, windows, colors, cbreak mode . Manual Screen refresh
  13. . Pronounced "oor'-wid" . Layered architecture . Display modules .

    Widget layout . Event loops introducing urwid
  14. . Pronounced "oor'-wid" . Layered architecture . Display modules .

    Widget layout . Event loops introducing urwid
  15. . Pronounced "oor'-wid" . Layered architecture . Display modules .

    Widget layout . Event loops introducing urwid
  16. . Pronounced "oor'-wid" . Layered architecture . Display modules .

    Widget layout . Event loops introducing urwid
  17. . Pronounced "oor'-wid" . Layered architecture . Display modules .

    Widget layout . Event loops introducing urwid
  18. resources Python Curses ------------- . Documentation http://docs.python.org/2/library/curses.html . Tutorial http://docs.python.org/2/howto/curses.html

    Urwid ----- . Documentation http://excess.org/urwid/docs/ . Tutorials http://excess.org/urwid/docs/tutorial/index.html#urwid-tutorial . Manual http://excess.org/urwid/docs/manual/index.html#urwid-manual