不确定这是否是你想要的。如果你点击第二个按钮
TextInput
它将复制第一个文件的内容
main.py
# main.py
from kivy.app import App
from kivy.properties import StringProperty
class AnswerApp(App):
text_of_text_input_1 = StringProperty()
def change_text_of_text_input_2(self):
self.text_of_text_input_1 = self.root.ids.text_input_1.text
if __name__ == "__main__":
AnswerApp().run()
和kv文件
answer.kv
.
# answer.kv
BoxLayout:
orientation: "vertical"
TextInput:
id: text_input_1
text: "text_input_1"
TextInput:
text: app.text_of_text_input_1
on_focus: app.change_text_of_text_input_2()