add support for Frames to find_with_pred in view_helpers
This commit is contained in:
parent
259c3c71e9
commit
07438a1049
|
@ -4,6 +4,8 @@ import urwid
|
|||
|
||||
def find_with_pred(w, pred, return_path=False):
|
||||
def _walk(w, path):
|
||||
if not isinstance(w, urwid.Widget):
|
||||
raise RuntimeError("_walk walked to non-widget %r via %r" % (w, path))
|
||||
if pred(w):
|
||||
return w, path
|
||||
if hasattr(w, '_wrapped_widget'):
|
||||
|
@ -15,6 +17,11 @@ def find_with_pred(w, pred, return_path=False):
|
|||
r, p = _walk(w, (w,) + path)
|
||||
if r:
|
||||
return r, p
|
||||
elif isinstance(w, urwid.Frame):
|
||||
for w, _ in w.contents.values():
|
||||
r, p = _walk(w, (w,) + path)
|
||||
if r:
|
||||
return r, p
|
||||
elif hasattr(w, 'contents'):
|
||||
contents = w.contents
|
||||
for w, _ in contents:
|
||||
|
|
Loading…
Reference in New Issue