From e85b2cfc4f0230704d065f3d85605645715b8229 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 7 Mar 2021 15:23:53 +0800 Subject: [PATCH] bugfix --- kivyblocks/blocks.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index bd11668..066328a 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -650,14 +650,29 @@ class Blocks(EventDispatcher): if hasattr(from_widget,'widget_id'): if from_widget.widget_id == id: return from_widget + if id[0] == '-' and from_widget.widget_id == id[1:]: + return from_widget if hasattr(from_widget, id): w = getattr(from_widget,id) if isinstance(w,Widget): return w - for c in from_widget.children: - ret = find_widget_by_id(id,from_widget=c) - if ret: - return ret + if id[0] == '-': + w = getattr(from_widget,id[1:]) + if isinstance(w,Widget): + return w + + if id[0] == '-': + print('find_widget_by_id(), id=', id, + 'widget=', from_widget) + if isinstance(from_widget, WindowBase): + return None + return find_widget_by_id(id, + from_widget=from_widget.parent) + else: + for c in from_widget.children: + ret = find_widget_by_id(id,from_widget=c) + if ret: + return ret return None ids = id.split('.')