我有一个标签和一个文本输入,我想通过.py文件上的一个变量更改它的text属性。 这是代码:
<DefinicaoDeSaidas>:
BoxLayout:
orientation:'vertical'
BoxLayout:
orientation:'vertical'
padding: 0,20,20,50
Image:
source:'exemplo.png'
Label:
text:'Escolha as missoes para a saida'
font_size:40
TextInput:
id: ti
class DefinicaoDeSaidas(Screen):
#get the values and everything
#transformate a variable ('name') onto the ti.text property
您可以通过github存储库查看所有代码:https://github.com/Enzodtz/FLL-Artificial-Inteligence
答案 0 :(得分:1)
请勿在.py中使用id,因为它通常会导致具有类似foo_object.ids.ti
的代码,相反,您可以将其公开为属性:
<DefinicaoDeSaidas>:
ti: ti # <---
BoxLayout:
orientation:'vertical'
BoxLayout:
orientation:'vertical'
padding: 0,20,20,50
Image:
source:'exemplo.png'
Label:
text:'Escolha as missoes para a saida'
font_size:40
TextInput:
id: ti
然后您可以通过任何方法使用self进行访问:
class DefinicaoDeSaidas(Screen):
# ...
def foo_function(self, another_arguments):
v = self.ti.text # get text
self.ti.text = u # update text