The goal of this series is to teach you how to use Button, TextInput, and ToggleButton in Kivy.
Let’s add a simple TextInput so something shows up on the screen.
We’ll import TextInput from kivy.uix.textinput
, and return it in our build()
function:
from kivy.app import App
from kivy.uix.textinput import TextInput
class MyKivy(App):
def build(self):
return TextInput(text="Enter your name", size_hint=(None,None), size=(200,50),pos_hint={'center_x': 0.5, 'center_y':0.5})
if __name__ == "__main__":
MyKivy().run()
Part 3: ToggleButton In Kivy
Let’s add a simple ToggleButton so something shows up on the screen.
We’ll import ToggleButton from kivy.uix.togglebutton
, and return it in our build()
function:
from kivy.app import App
from kivy.uix.togglebutton import ToggleButton
class MyKivy(App):
def build(self):
return ToggleButton(text="Unchecked", size_hint=(None,None), size=(200,50),pos_hint={'center_x': 0.5, 'center_y':0.5}, allow_no_selection=False)
if __name__ == "__main__":
MyKivy().run()
If you enjoyed this video, please like, subscribe, and hit the bell icon so you don’t miss the next lesson.
And if anything was unclear, drop a comment — I’m always here to help.
Thanks for watching — I’ll see you in the next tutorial.
Until then, peace and happy coding!
Social Media Accounts: