Deprecated Classes

class urwid.FlowWidget(*args, **kwargs)

Deprecated. Inherit from Widget and add:

_sizing = frozenset([‘flow’])

at the top of your class definition instead.

Base class of widgets that determine their rows from the number of columns available.

render(size: tuple[int], focus: bool = False) Canvas

All widgets must implement this function.

rows(size: int, focus: bool = False) int

All flow widgets must implement this function.

class urwid.BoxWidget(*args, **kwargs)

Deprecated. Inherit from Widget and add:

_sizing = frozenset([‘box’]) _selectable = True

at the top of your class definition instead.

Base class of width and height constrained widgets such as the top level widget attached to the display object

render(size: tuple[int, int], focus: bool = False) Canvas

All widgets must implement this function.

class urwid.FixedWidget(*args, **kwargs)

Deprecated. Inherit from Widget and add:

_sizing = frozenset([‘fixed’])

at the top of your class definition instead.

Base class of widgets that know their width and height and cannot be resized

pack(size: tuple[()] = (), focus: bool = False) tuple[int, int]

All fixed widgets must implement this function.

render(size: tuple[()], focus: bool = False) Canvas

All widgets must implement this function.

class urwid.AttrWrap(w: Widget, attr, focus_attr=None)

w – widget to wrap (stored as self.original_widget) attr – attribute to apply to w focus_attr – attribute to apply when in focus, if None use attr

This widget is a special case of the new AttrMap widget, and it will pass all function calls and variable references to the wrapped widget. This class is maintained for backwards compatibility only, new code should use AttrMap instead.

>>> from urwid import Divider, Edit, Text
>>> AttrWrap(Divider(u"!"), 'bright')
<AttrWrap flow widget <Divider flow widget '!'> attr='bright'>
>>> AttrWrap(Edit(), 'notfocus', 'focus')
<AttrWrap selectable flow widget <Edit selectable flow widget '' edit_pos=0> attr='notfocus' focus_attr='focus'>
>>> size = (5,)
>>> aw = AttrWrap(Text(u"hi"), 'greeting', 'fgreet')
>>> next(aw.render(size, focus=False).content())
[('greeting', None, ...'hi   ')]
>>> next(aw.render(size, focus=True).content())
[('fgreet', None, ...'hi   ')]
set_attr(attr: Hashable) None

Set the attribute to apply to the wrapped widget

>> w = AttrWrap(Divider(“-“), None) >> w.set_attr(‘new_attr’) >> w <AttrWrap flow widget <Divider flow widget ‘-’> attr=’new_attr’>

set_focus_attr(focus_attr: Hashable) None

Set the attribute to apply to the wapped widget when it is in focus

If None this widget will use the attr instead (no change when in focus).

>> w = AttrWrap(Divider(“-“), ‘old’) >> w.set_focus_attr(‘new_attr’) >> w <AttrWrap flow widget <Divider flow widget ‘-’> attr=’old’ focus_attr=’new_attr’> >> w.set_focus_attr(None) >> w <AttrWrap flow widget <Divider flow widget ‘-’> attr=’old’>

sizing() frozenset[Sizing]
Returns:

A frozenset including one or more of 'box', 'flow' and 'fixed'. Default implementation returns the value of _sizing, which for this class includes all three.

The sizing modes returned indicate the modes that may be supported by this widget, but is not sufficient to know that using that sizing mode will work. Subclasses should make an effort to remove sizing modes they know will not work given the state of the widget, but many do not yet do this.

If a sizing mode is missing from the set then the widget should fail when used in that mode.

If 'flow' is among the values returned then the other methods in this widget must be able to accept a single-element tuple (maxcol,) to their size parameter, and the rows() method must be defined.

If 'box' is among the values returned then the other methods must be able to accept a two-element tuple (maxcol, maxrow) to their size parameter.

If 'fixed' is among the values returned then the other methods must be able to accept an empty tuple () to their size parameter, and the pack() method must be defined.

property w: Widget

backwards compatibility, widget used to be stored as w