[Urwid] Rendering and caching

Ian Ward ian at excess.org
Fri Oct 26 10:28:59 EDT 2007

Aaron Gallagher wrote:
> How are rendered objects cached, and how does urwid know when to call 
> the render function? I've tried making my own widgets, but they only 
> seem to work if I call render functions from preexisting widgets; 
> returning my own canvases renders once, but never calls render again. I 
> would also like to know how can I force rerendering given an object?

Since release 0.9.8 all widgets cache the result of the render function:

If the result is in the cache then it will be returned instead of 
calling the actual render function.  If your widget has changed and will 
render differently then it should call self._invalidate() to clear its 
canvas from the cache.

You can also disable the cache for your widget by including 
"no_cache=['render']" in your class definition, but that will have a 
negative impact on performance.

> And is there any way to make text markup easier? Using lists of markup 
> lists is bothering me a bit.

I'm open to suggestions.  Would you prefer some type of escape codes in 
the text?


More information about the Urwid mailing list