Urwid Display Modules
Table of Contents
Documentation in devlopment
Introduction
Urwid's display modules provide a layer of abstraction for drawing to the screen and reading user input. It should be possible to switch between any of the display modules without writing custom code for each one.
Console Display Modules raw_display and curses_display
Urwid has two display modules for displaying to terminals or the console.
The raw_display module is a pure-python display module with no external dependencies. It sends and interprets terminal escape seqences directly.
The curses_display module uses the curses or ncurses library provided by the operating system. The library handles optimization of screen updates.
The (n)curses library will disable colours if it detects a monochrome terminal, so a separate set of attributes should be given for monochrome mode when registering a palette with curses_display.
This table summarizes the differences between the two modules:
| raw_display | curses_display | |
| optimized C code | no | YES |
| UTF-8 support | YES | YES * |
| bright foreground without bold | YES ** | no |
| mouse dragging support | YES | no |
| external event loop support | YES | no |
*if python is linked against the wide version of ncurses
**when using xterm or gnome-terminal
curses_display.Screen reference
AJAX-based Web Display Module web_display
The web_display module lets you run your application as a CGI script under Apache instead of running it in a terminal.
This module is a proof of concept. There are security and responsiveness issues that need to be resolved before this module is recommended for production use.
The tour.py and calc.py example programs demonstrate use of this module.
live demo of web_display module
Screenshot Display Module html_fragment
Since Urwid is a console display library screenshots of Urwid interfaces can be rendered in plain HTML. The html_fragment display module lets you do this by simulating user input and capturing the screen as fragments of HTML each time draw_screen() is called.
These fragments may be included in HTML documents. They will be rendered properly by any browser that uses a monospaced font for text that appears in <pre> tags. HTML screenshots have text that is searchable and selectable in a web browser, and they will shrink and grow when a user changes their browser's text size.
Attachments
- display_modules.png (15.8 kB) - added by ian on 12/18/06 17:50:33.
- display_modules.svg (22.3 kB) -
Source for display_modules.png
, added by ian on 12/18/06 17:53:43.

