我正在编写一个程序,我想将多个标签的文本更改为大写。但我的程序似乎只将最后一个文本更改为大写。这是我的程序。在这里,只有 c 被转换为大写。a 和 b 保持小写。我哪里错了?
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.togglebutton import ToggleButton
from kivy.lang import Builder
Builder.load_string('''
<box>:
ToggleButton:
text: 'Caps Lock'
on_state:
if self.state == 'down': lol.text = lol.text.upper()
elif self.state == 'normal': lol.text = lol.text.lower()
Label:
id: lol
text: 'a'
Label:
id: lol
text: 'b'
Label:
id: lol
text: 'c'
''')
class box(BoxLayout):
pass
class main(App):
def build(self):
return box()
if __name__ == "__main__":
main().run()