当我按下一个按钮时,我正在尝试更改淡紫色文本,但它不会更改我有以下代码:
控制器:
class Controller(BoxLayout):
random_string = StringProperty()
random_string="hola"
def do_action(self):
random_string="h22l"
print(random_string)
def do_action2(self):
random_string="hl2332323"
print(str(random_string))
我的.mk:
<Controller>:
label: lvId
BoxLayout:
orientation: 'vertical'
Button:
text: 'Click Me'
on_press: root.do_action()
Button:
text: 'Click Me'
on_press: root.do_action2()
Label:
id: lvId
text: root.random_string
text_size: root.width, None
size: self.texture_size
必须通过
self
访问变量,否则,将创建一个新的局部变量,而不是要访问的局部变量。你知道吗相关问题 更多 >
编程相关推荐