Build native Android and iOS apps in Python.
Documentation · Getting Started · Examples · Contributing
PythonNative is a cross-platform toolkit for building native Android and iOS apps in Python. It provides a declarative, React-like component model with automatic reconciliation, powered by Chaquopy on Android and rubicon-objc on iOS. Describe your UI as a tree of elements, manage state with set_state(), and let PythonNative handle creating and updating native views.
- Declarative UI: Describe what your UI should look like with element functions (
Text,Button,Column,Row, etc.). PythonNative creates and updates native views automatically. - Reactive state: Call
self.set_state(key=value)and the framework re-renders only what changed — no manual view mutation. - Virtual view tree + reconciler: Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation.
- Direct native bindings: Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
- CLI scaffolding:
pn initcreates a ready-to-run project;pn run androidandpn run iosbuild and launch your app. - Navigation: Push and pop screens with argument passing for multi-page apps.
- Bundled templates: Android Gradle and iOS Xcode templates are included — scaffolding requires no network access.
pip install pythonnativeimport pythonnative as pn
class MainPage(pn.Page):
def __init__(self, native_instance):
super().__init__(native_instance)
self.state = {"count": 0}
def render(self):
return pn.Column(
pn.Text(f"Count: {self.state['count']}", font_size=24),
pn.Button(
"Tap me",
on_click=lambda: self.set_state(count=self.state["count"] + 1),
),
spacing=12,
padding=16,
)| Component | Description |
|---|---|
Text |
Display text |
Button |
Tappable button with on_click callback |
Column / Row |
Vertical / horizontal layout containers |
ScrollView |
Scrollable wrapper |
TextInput |
Text entry field with on_change callback |
Image |
Display images |
Switch |
Toggle with on_change callback |
ProgressBar |
Determinate progress (0.0–1.0) |
ActivityIndicator |
Indeterminate loading spinner |
WebView |
Embedded web content |
Spacer |
Empty space |
Visit docs.pythonnative.com for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.
Contributions are welcome. Please see CONTRIBUTING.md for setup instructions, coding standards, and guidelines for submitting pull requests.
