In this video we’ll start to look at using input boxes and buttons with Kivy and Python.

Input boxes and buttons are the most basic input/output type things in any programming language, and they’re pretty easy to use with Kivy. We’ll also start to look at GridLayout for arranging the layout of our app.


import kivy
from import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class MyGridLayout(GridLayout):
	# Initialize infinite keywords
	def __init__(self, **kwargs):
		# Call grid layout constructor
		super(MyGridLayout, self).__init__(**kwargs)

		# Set columns
		self.cols = 2

		# Add widgets
		self.add_widget(Label(text="Name: "))
		# Add Input Box = TextInput(multiline=True)

		self.add_widget(Label(text="Favorite Pizza: "))
		# Add Input Box = TextInput(multiline=False)

		self.add_widget(Label(text="Favorite Color: "))
		# Add Input Box
		self.color = TextInput(multiline=False)

		# Create a Submit Button
		self.submit = Button(text="Submit", font_size=32)
		# Bind the button

	def press(self, instance):
		name =
		pizza =
		color = self.color.text

		#print(f'Hello {name}, you like {pizza} pizza, and your favorite color is {color}!')
		# Print it to the screen
		self.add_widget(Label(text=f'Hello {name}, you like {pizza} pizza, and your favorite color is {color}!'))

		# Clear the input boxes = "" = ""
		self.color.text = ""

class MyApp(App):
	def build(self):
		return MyGridLayout()

if __name__ == '__main__':

John Elder

John is the CEO of where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder