From ac8ff8b36e5865c71dbc01ef7905b480e421d789 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 7 Feb 2021 19:49:10 +0800 Subject: [PATCH] bugfix --- kivyblocks/blocks.py | 22 ++++++++++++++-------- kivyblocks/markdown.py | 8 ++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index ed635ca..d9c6fb8 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -627,6 +627,7 @@ class Blocks(EventDispatcher): @classmethod def getWidgetById(self,id,from_widget=None): + print('getWidgetById(%s,%s) ...' % (id, from_widget)) def find_widget_by_id(id, from_widget): if id=='self': return from_widget @@ -641,12 +642,6 @@ class Blocks(EventDispatcher): ret = find_widget_by_id(id,from_widget=c) if ret: return ret - app = App.get_running_app() - if from_widget == app.root: - if Window.fullscreen == True: - w = app.fs_widget - if w: - return find_widget_by_id(id, w) return None ids = id.split('.') @@ -654,18 +649,29 @@ class Blocks(EventDispatcher): fid = ids[0] if fid == '/self' or fid == 'root': from_widget = app.root - ids[0] = 'self' + if len(ids) == 1: + return from_widget + ids = ids[1:] if fid == 'Window': from_widget == Window - ids[0] = 'self' + if len(ids) == 1: + return from_widget + ids = ids[1:] if fid == 'app': return app if from_widget is None: from_widget = app.root for id in ids: + print('finding', id) w = find_widget_by_id(id,from_widget=from_widget) + if w is None \ + and id == ids[0] \ + and Window.fullscreen == True \ + and app.root != app.fs_widget: + w = find_widget_by_id(id, app.fs_widget) if w is None: + print(id, 'not found ....') return None from_widget = w return w diff --git a/kivyblocks/markdown.py b/kivyblocks/markdown.py index b86d619..d0e5cf1 100644 --- a/kivyblocks/markdown.py +++ b/kivyblocks/markdown.py @@ -25,6 +25,12 @@ description file format self.bind(source=self.load_text) if self.source: Clock.schedule_once(self.load_text, 0.3) + self.bind(size=self.setChildMinWidth) + + def setChildMinWidth(self, *args): + print('size changed') + for c in self._inner.children: + c.width = self.width def load_text(self, *args): print('source fired, hahaha', *args) @@ -52,6 +58,7 @@ description file format "text":txt, "size_hint_x":None, "width":self.width, + "minimum_width":self.width, "size_hint_y":None, "markup":True, "wrap":True, @@ -95,6 +102,7 @@ description file format "wrap":True, "size_hint_x":None, "width":self.width, + "minimum_width":self.width, "markup":True, "valign":"middle", "halign":"left"