mirror of https://github.com/kivy/kivy.git
fix kivycatalog reload issue
This commit is contained in:
parent
bb79e585ef
commit
b5a67b02aa
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue