From a347ee9f06ca3768202d18e90d673f13e05ccba6 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 7 Aug 2020 20:59:42 +0800 Subject: [PATCH] bugfix --- kivyblocks/blocks.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index a729f5b..c1b1ad0 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -262,11 +262,18 @@ class Blocks(EventDispatcher): if desc.get('id'): myid = desc.get('id') holder = ancestor + if myid[0] == '/': + myid = myid[1:] + app = App.get_running_app() + holder = app.root + if ancestor == widget: app = App.get_running_app() holder = app.root + if not hasattr(holder,'widget_ids'): setattr(holder,'widget_ids',{}) + holder.widget_ids[myid] = widget widget.build_desc = desc @@ -475,6 +482,10 @@ class Blocks(EventDispatcher): for id in ids: if id == 'self': return widget + if not hasattr(widget, 'widget_ids'): + print('widget not found,path=',path,'id=',id,'ids=',ids) + raise WidgetNotFoundById(id) + widget = widget.widget_ids.get(id,None) if widget is None: print('widget not found,path=',path,'id=',id,'ids=',ids)