Deprecated Classes

class urwid.AttrWrap(w: WrappedWidget, attr: Hashable | Mapping[Hashable, Hashable], focus_attr: Hashable | Mapping[Hashable, Hashable] = None)

A special case of the AttrMap widget.

Passes all function calls and variable references on to the wrapped widget.

Deprecated since version 0.9.9: Maintained for backwards compatibility only, new code should use AttrMap instead.

Build the widget from an existing widget and attribute mapping.

Parameters:
  • 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

Deprecated since version 0.9.9: Maintained for backwards compatibility only, new code should use AttrMap instead.

>>> from urwid import Divider, Edit, Text
>>> AttrWrap(Divider("!"), "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("hi"), "greeting", "fgreet")
>>> next(aw.render(size, focus=False).content())
[('greeting', None, ...'hi   ')]
>>> next(aw.render(size, focus=True).content())
[('fgreet', None, ...'hi   ')]
property attr: Hashable

Return the attribute applied to the wrapped widget.

property focus_attr: Hashable | None

Return the attribute applied to the wrapped widget when it is in focus.

get_attr() → Hashable

Return the attribute applied to the wrapped widget.

get_focus_attr() → Hashable | None

Return the attribute applied to the wrapped widget when it is in focus.

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 wrapped 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]

Return the sizing modes supported by the wrapped widget.

property w: WrappedWidget

The wrapped widget.

Deprecated since version 0.9.9: The widget used to be stored as w. Use original_widget instead. This API will be removed in version 5.0.

class urwid.MetaSuper

Metaclass kept only so that existing class definitions keep importing.

All logic has been removed; it is a plain type subclass.

Deprecated since version 3.0.0: Drop it from the class bases. While it is still listed, move it to the last position, so that future changes to the other bases are not blocked by it.