Skip to content Skip to sidebar Skip to footer

How To Get Data Of User Input From A For Loop To Python File In Kivymd

i am making an app to multiply 2 matrix. for that i created the user interface but cant figure it out how to get the user input in my python file, so i can do operations there. he

Solution 1:

Store references to your text fields, and access them later to do what you want.

I would delete your on_parent, replace the GridLayout with your own class MyGridLayout(GridLayout):, and have that class do:

def__init__(self, **kwargs):
    super().__init__(**kwargs)
    self.text_fields = [MdTextField(hint_text= 'sc', helper_text= 'hello', size_hint_x= None, width = 40))] for _ inrange(16)]

Then later when you want to access them, you can iterate through e.g. entered_numbers = [int(field.text) for field in self.text_field].

Of course that's just a basic example, in reality you'll want error checking etc.

Post a Comment for "How To Get Data Of User Input From A For Loop To Python File In Kivymd"