GPU-accelerated, multi-touch toolkit for mobile, desktop and custom game-like UIs.
Kivy is an open-source Python framework for building multitouch applications. Unlike tkinter or wxPython, Kivy does not use native OS widgets โ it renders everything with OpenGL ES 2, giving a consistent look across Windows, macOS, Linux, Android, and iOS. This makes it the primary choice for Python developers who need mobile deployment or touchscreen kiosks.
Kivy was created by the Kivy organization and is used in education, museums, industrial HMIs, and indie games. UIs can be built in pure Python or split between Python logic and the declarative KV language (similar to QML).
kivy.app.App; implement build() to return the root widget.BoxLayout, GridLayout, FloatLayout) contain child widgets.text, pos, size) are reactive; bind with widget.bind(on_press=callback).Clock.schedule_interval() for animations and game loops..kv files define layout and styling declaratively.| Tool | Target |
|---|---|
| Buildozer | Android APK/AAB (Linux build recommended) |
| python-for-android | Low-level Android build recipes |
| kivy-ios | iOS builds (requires macOS + Xcode) |
pip install kivy
# Optional extras:
pip install kivy[base,media]
# For Android builds (on Linux):
pip install buildozer
from kivy.app import App
from kivy.uix.button import Button
class DemoApp(App):
def build(self):
btn = Button(text="Tap me", font_size=28)
btn.bind(on_press=lambda *_: print("tapped"))
return btn
DemoApp().run()
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
class CounterApp(App):
def build(self):
self.count = 0
layout = BoxLayout(orientation="vertical", padding=20, spacing=10)
self.label = Label(text="0", font_size=48)
btn = Button(text="Add", size_hint=(1, 0.2))
btn.bind(on_press=self.add)
layout.add_widget(self.label)
layout.add_widget(btn)
return layout
def add(self, *_):
self.count += 1
self.label.text = str(self.count)
CounterApp().run()
Save layout in a .kv file named after your App class (DemoApp โ demo.kv):
<DemoApp>:
BoxLayout:
orientation: 'vertical'
padding: 30
Label:
text: 'Hello from KV'
font_size: 32
Button:
text: 'Quit'
on_press: app.stop()
from kivy.app import App
class DemoApp(App): pass
DemoApp().run()
size_hint and pos_hint instead of fixed pixel sizes for responsive layouts.ScreenManager for multi-screen apps (login โ main โ settings).You need a mobile app, a touchscreen kiosk, or a game-like custom interface from Python. Avoid when native desktop appearance or simple forms are the priority.
Useful guides and tools (from webpage_links.xlsx).