Deprecated Classes¶
- class urwid.AttrWrap(w: WrappedWidget, attr: Hashable | Mapping[Hashable, Hashable], focus_attr: Hashable | Mapping[Hashable, Hashable] = None)¶
A special case of the
AttrMapwidget that 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
AttrMapinstead.- 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
AttrMapinstead.>>> 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 ')]
- 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 theirsizeparameter, and therows()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 thepack()method must be defined.
- property w: WrappedWidget¶
The wrapped widget.
Deprecated since version 0.9.9: The widget used to be stored as
w. Useoriginal_widgetinstead. 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
typesubclass.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.