kivy: simplify bind

This commit is contained in:
ThomasV 2016-02-04 20:14:11 +01:00
parent 45a0c3b53b
commit 3d42193223
2 changed files with 2 additions and 7 deletions

View File

@ -18,16 +18,11 @@ class _(str):
return _.lang(s).format(args, kwargs) return _.lang(s).format(args, kwargs)
@staticmethod @staticmethod
def bind(label, arg): def bind(label):
if not isinstance(label.text, _):
return
if label.bound:
return
try: try:
_.observers.add(label) _.observers.add(label)
except: except:
pass pass
label.bound = True
# garbage collection # garbage collection
new = set() new = set()
for label in _.observers: for label in _.observers:

View File

@ -13,7 +13,7 @@
font_name: 'Roboto' font_name: 'Roboto'
font_size: '16sp' font_size: '16sp'
bound: False bound: False
on_text: _.bind(self, args[1]) on_text: if isinstance(self.text, _) and not self.bound: self.bound=True; _.bind(self)
<TextInput> <TextInput>
on_focus: app._focused_widget = root on_focus: app._focused_widget = root