Skip to content

pythonnative/pythonnative

Repository files navigation

PythonNative

Build native Android and iOS apps in Python.

CI Release PyPI Version Python Versions License: MIT Docs

Documentation · Getting Started · Examples · Contributing


Overview

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.

Features

  • 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 init creates a ready-to-run project; pn run android and pn run ios build 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.

Quick Start

Installation

pip install pythonnative

Usage

import 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,
        )

Available Components

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

Documentation

Visit docs.pythonnative.com for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.

Contributing

Contributions are welcome. Please see CONTRIBUTING.md for setup instructions, coding standards, and guidelines for submitting pull requests.

License

MIT