D
D
Demych Demkin2022-01-07 04:19:29
Python
Demych Demkin, 2022-01-07 04:19:29

How to pass text from MDTextFieldRect to a function?

Tell me, please, I have already rummaged through everything that is possible
. How can I transfer its contents from MDTextFieldRect (located in the main.kv file) after pressing the "Enter" key to the input function in the main.py file?

main.py file

from kivymd.app import MDApp
from kivy.uix.boxlayout import BoxLayout
from kivymd.uix.textfield import MDTextFieldRect

class Container(BoxLayout):
    pass

class MainApp(MDApp):
    def input(self, value):
        Snackbar(text=value).open()

    def build(self):
        all = Container()
        return all

MainApp().run()


Main.kv file
#:import MDField kivymd.uix.textfield
<Container>:
    orientation: "vertical"
       
    MDTextFieldRect:
        multiline: False
        text: 'text'
        on_text_validate:  app.input()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PosikGG, 2022-01-07
@PosikGG

Through f = open () did not try?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question