How to retrieve the value of an MDTextFieldRound on kivyMD?

492 views Asked by At

I've been looking for a few days how to retrieve the text written in MDTextFieldRound on Kivy. So if you have the answers to my questions do not hesitate to write. Blux

1

There are 1 answers

2
JanPodavka On BEST ANSWER

It works best for me if I set a texfield id, which I then access in python. For example in .kv:

MDTextFieldRect:
      id: user_name  (Here is a id)
      font_size: 0.65 * self.height
      size_hint: 1, .8
      max_text_length: 9
      pos_hint: {"center_x": .5, "center_y": .5}

And then in in .py: When you want to change a text in field:

class ProfileWindow(Screen):

    def clear_info(self):
        self.ids['user_name'].text = ""
        self.ids['user_pass'].text = ""
        self.ids['user_address'].text = ""
        self.ids['user_number'].text = ""

Or if you want to get the text from text field:

def clear_info(self):

    name = self.ids['user_name'].text