clickable text in kivy code example

Example: clickable text in kivy

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.boxlayout import BoxLayout

class CustomeBoxLayout(BoxLayout):
    def __init__(self, **Kwargs):
        super(CustomeBoxLayout,self).__init__(**Kwargs)
        text_input_1 = TextInput(text = "Your Input", multiline=False)        
        text_input_2 = TextInput(text = "Your Output", multiline=False)        
        button_1 = Button(text = "Button 1")        
        button_2 = Button(text = "Button 2")
        
        button_1.bind(on_press = lambda button: self.click_button_1(text_input_1.text))

        self.add_widget(text_input_1)
        self.add_widget(text_input_2)
        self.add_widget(button_1)
        self.add_widget(button_2)
    
    def click_button_1(self,text):        
        print (text)
    
class TestApp(App):
    def build(self):
        return CustomeBoxLayout()

if __name__ == "__main__":
    app = TestApp()
    app.run()

Tags:

Misc Example