KiviMD 对话框中的重复文本字段小部件

Duplicate textfield widgets in the KiviMD dialog

为什么单击“更改密码”按钮会打开一个包含重复文本字段小部件的对话框? 我完全用 .py 代码编写的代码工作正常但不清楚。这就是为什么我将它转录成 .kv 语言。

enter image description here

demo2.py

from kivy.lang import Builder
from kivymd.app import MDApp
from kivy.uix.screenmanager import Screen, ScreenManager
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button  import MDFillRoundFlatButton,MDIconButton ,MDFlatButton
from kivymd.uix.textfield import MDTextField
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty


PASSWORD = ["admin"]

class Content(MDBoxLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
    

class UserScreen(Screen):
    pass

class DataScreen(Screen):
    pass

class Manager(ScreenManager):

    id = {}

    # def __init__(self, **kwargs):
    #     super().__init__(**kwargs)
        
    #     Manager.id["password"] = self.children[0].children[2]
    #     print(ChangePasswordScreen.x)

    def click(self):
        
        if Manager.id["password"].text == PASSWORD[0]:
            Manager.id["password"].text = ""
            self.current = "data_screen"
            self.transition.direction = "up"
        else:
            Manager.id["password"].text = ""
            print("špatné heslo")
    
    def show_change_password(self):

        print()

    
        
        self.dialog = MDDialog(
            title="Change password",
            type="custom",
            content_cls=Content(),  
            buttons=[
                MDFlatButton(
                    text="CANCEL",
                    theme_text_color="Custom",
                    # text_color=DemoApp.styl.primary_color,
                ),
                MDFlatButton(
                    text="OK",
                    theme_text_color="Custom",
                    # text_color=DemoApp.styl.primary_color,
                ),
            ],
        )
        
        self.dialog.open()

        

        # self.dialog.buttons[1].on_press = self.change_password
        self.dialog.buttons[0].on_press = self.dialog.dismiss
        

class Demo2App(MDApp):
    styl = None
    def build(self):
        
        self.theme_cls.primary_palette = "Red"
        self.theme_cls.accent_palette = "Green"
        self.styl = self.theme_cls
        Builder.load_file("demo2.kv")
        
Demo2App().run()

demo2.kv

<Content>:
    id: mywidget
    orientation:"vertical"
    spacing:"12dp"
    size_hint_y:None
    height:"200dp"
    MDTextField:
        hint_text:"current password "
        password:True
        pos_hint:{"center_x":0.5, "center_y":0.6}
        size_hint_x:None
        width:200
        focus:True
    MDTextField:
        hint_text:"New password"
        password:True
        pos_hint:{"center_x":0.5, "center_y":0.6}
        size_hint_x:None
        width:200
    MDTextField:
        hint_text:"Check new password "
        password:True
        pos_hint:{"center_x":0.5, "center_y":0.6}
        size_hint_x:None
        width:200


Manager: 
    UserScreen:
        name: "user_screen"
        MDLabel:
            id:user_title
            text:"Přihlášení do databáze"
            font_style:"H4"
            pos_hint:{"center_x":0.5, "center_y":0.8}
            size_hint_x: None
            width: 500
            halign:"center"
            theme_text_color:"Secondary"
        MDTextField:
            id: password
            hint_text:"Password"
            password:True
            pos_hint:{"center_x":0.5, "center_y":0.6}
            size_hint_x:None
            width:200
            focus:True
        MDFlatButton:
            text:"Change password "
            pos_hint:{"center_x":0.5, "center_y":0.55}
            font_size:11
            on_press: root.show_change_password()
        MDFillRoundFlatButton:
            text:"Entry"
            pos_hint:{"center_x":0.5, "center_y":0.4}
            on_press:root.click()
    DataScreen:
        name: "data_screen"