From 07438a1049a2ae7bb7d22c0bf16013d552cb01f5 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 1 May 2018 12:17:53 +1200 Subject: [PATCH] add support for Frames to find_with_pred in view_helpers --- subiquitycore/testing/view_helpers.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subiquitycore/testing/view_helpers.py b/subiquitycore/testing/view_helpers.py index 0a6d3d8c..f6c0f8f4 100644 --- a/subiquitycore/testing/view_helpers.py +++ b/subiquitycore/testing/view_helpers.py @@ -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: