From b5a67b02aa19d5abde4c0a117ee7dbfac082a495 Mon Sep 17 00:00:00 2001 From: Ryan Pessa Date: Thu, 1 Jan 2015 14:58:47 -0600 Subject: [PATCH] fix kivycatalog reload issue --- examples/demo/kivycatalog/main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/demo/kivycatalog/main.py b/examples/demo/kivycatalog/main.py index e6e180f21..1269ec475 100755 --- a/examples/demo/kivycatalog/main.py +++ b/examples/demo/kivycatalog/main.py @@ -39,7 +39,8 @@ class Container(BoxLayout): def __init__(self, **kwargs): super(Container, self).__init__(**kwargs) - parser = Parser(content=open(self.kv_file).read()) + self.previous_text = open(self.kv_file).read() + parser = Parser(content=self.previous_text) widget = Factory.get(parser.root.name)() Builder._apply_rule(widget, parser.root, parser.root) self.add_widget(widget) @@ -112,15 +113,18 @@ class Catalog(BoxLayout): child = self.screen_manager.current_screen.children[0] with open(child.kv_file, 'rb') as file: self.language_box.text = file.read().decode('utf8') + Clock.unschedule(self.change_kv) + self.change_kv() # reset undo/redo history self.language_box.reset_undo() def schedule_reload(self): if self.auto_reload: txt = self.language_box.text - if txt == self._previously_parsed_text: + child = self.screen_manager.current_screen.children[0] + if txt == child.previous_text: return - self._previously_parsed_text = txt + child.previous_text = txt Clock.unschedule(self.change_kv) Clock.schedule_once(self.change_kv, 2)