如何在第二个屏幕上将 MDTextField 输入与标签文本绑定

How to bind MDTextField input with Label's text on second screen

我已经开始创建小应用程序,但遇到了困难。我从这个论坛尝试了许多不同的想法,但没有一个适合我的应用程序。我已经很困惑我应该怎么做。 我想要的只是从 MDTextField(由用户提供)获取输入并将其显示在第二个屏幕上的标签文本中。

我的 .kv 文件:

ScreenManager:
    First:
    Second:

<First@Screen>:
    name: 'screen1'
    MDTextFieldRound: 
        id: getpath
        text: "Enter player name"
        pos_hint: {'center_x': 0.5, 'center_y': 0.5}
        size_hint_x: None
        width: 300
        mode: "rectangle"
        icon_right: "scissors-cutting"
    MDRectangleFlatButton:
        text: "Submit"
        pos_hint: {'center_x': .5, 'center_y': 0.4}
        on_release: root.manager.current = 'screen2'
<Second@Screen>:
    name: 'screen2'
    canvas:
        Rectangle:
            source: 'image.jpg'
            pos: self.pos
            size: self.size
    Label:
        id: lab
        text: ''

我的main.py:

class PKNApp(MDApp):
    def build(self):
        pass


PKNApp().run()

如果您在 kv 中为 First Screen 添加 id,如下所示:

ScreenManager:
    First:
        id: first
    Second:

然后你可以使用 id 访问 TextInput,像这样:

Label:
    id: lab
    text: root.manager.ids.first.ids.getpath.text