Why the textinput value isn't updated with this code? I need to capture the value typed by the user when I click on the button, but no matter what it seems that I can only get the default text.
This is a runnable example on python 3.4.3:
# -*- coding: utf-8 -*-
import kivy
kivy.require("1.9.1")
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from functools import partial
class TestApp(App):
def check(self, texto, *args):
print(texto)
def build(self):
layout = FloatLayout()
txtinput = TextInput(background_color=(1,1,1,1),
font_size=16,
size_hint=(None, None),
size=(200, 35),
pos_hint={"center_x":0.5, "bottom":0.8},
multiline=False,
text="write here...",
use_bubble=True)
boton = Button(size_hint=(None, None),
size=(150, 50),
pos_hint={"left":1, "bottom":1},
text="Check",
on_release=partial(self.check, txtinput.text))
layout.add_widget(txtinput)
layout.add_widget(boton)
return layout
if __name__ == "__main__":
TestApp().run()
I'd like a pure Python answer, I don't really like to use kv files.