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)