[Urwid] Creating a border around a widget

Sébastien Pierre sebastien at xprima.com
Fri Aug 11 10:39:01 EDT 2006


Hi all,

I recently tried to wrap a widget so that there was a border of 1
character around, as follows:

  BBBBBBBBBBBBB         B = Border
  B...........B         . = Widget
  BBBBBBBBBBBBB

Looking at the dialog example, I found the following code:

  w = urwid.Padding(w, ('fixed left', 1), ('fixedright', 1))
  w = urwid.Filler(w,  ('fixed top', 1),  ('fixed bottom',1))

which, as I understand it, creates a left and right border, then a top
and bottom border.

However, when using this method to wrap any widget, I get the following
traceback:

  File "urwid/widget.py", line 1661, in render
    focus and self.focus_part == 'body')
  File "urwid/listbox.py", line 248, in render
    middle, top, bottom = self.calculate_visible(
  File "urwid/listbox.py", line 203, in calculate_visible
    n_rows = next.rows ( (maxcol,) )
  AttributeError: Filler instance has no attribute 'rows'

It seems like Filler does not implement the `rows` method... is it on
purpose ?

This leads me to the fact that it would be really nice to define a
global Widget interface, and a global Container interface, so that we
can really know what methods are required in the layout process.

 -- Sébastien





More information about the Urwid mailing list