Skip to main content

Cross-platform native UI toolkit for Android and iOS

Project description

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 hooks and automatic reconciliation, powered by Chaquopy on Android and rubicon-objc on iOS. Write function components with use_state, use_effect, and friends, just like React, 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.
  • Rich component library: 25+ built-in components backed by real native widgets — TextInput, Image / ImageBackground, ScrollView, FlatList / SectionList, Modal, Pressable / TouchableOpacity, Switch / Checkbox, Slider, SegmentedControl, Picker, DatePicker, ProgressBar / ActivityIndicator, WebView, and more.
  • Device APIs: Cross-platform modules for Camera, Location, FileSystem, Notifications, Clipboard, Share, Linking, Permissions, AppState, NetInfo, SecureStore, Battery, Haptics / Vibration, and Biometrics — plus reactive use_app_state and use_net_info hooks.
  • Hooks and function components: Manage state with use_state, side effects with use_effect, and navigation with use_navigation, all through one consistent pattern.
  • Typed style prop: Pass all visual and layout properties through a single style dict, fully described by the pn.Style TypedDict and the ergonomic pn.style(...) helper for IDE autocomplete and static checking. Compose reusable styles with StyleSheet.
  • Cross-platform flexbox engine: A pure-Python, Yoga-style layout engine computes frames once and applies them to native views, so flex, padding, aspect_ratio, and position: "absolute" produce the same geometry on Android and iOS.
  • Virtual view tree + reconciler: Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation. State updates re-render locally — only the component whose state changed (and its subtree) re-runs, and unchanged leaves reuse cached intrinsic measurements — so deep UIs stay responsive instead of re-rendering the whole app from the root on every tap.
  • Direct native bindings: Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
  • Custom-component SDK: Wrap any platform widget as a first-class element with type-checked props via pythonnative.sdk (Props, @native_component, element_factory). Plugins distributed on PyPI auto-register through the pythonnative.handlers entry-point group.
  • CLI scaffolding: pn init creates a ready-to-run project; pn run android and pn run ios build and launch your app.
  • Instant desktop preview: pn preview renders your app in a native desktop window via Tkinter with Fast Refresh on every save — iterate on layout, state, and navigation in milliseconds without booting a simulator or device. The reconciler, hooks, layout engine, and navigation are the same code that ships to the phone.
  • Native-backed navigation: Declarative Stack, Tab, and Drawer navigators inspired by React Navigation. The root stack drives the platform's native navigation controller (UINavigationController on iOS, AndroidX Navigation Component on Android), so transitions, back gestures, and the hardware back button match what users expect.
  • Fast Refresh hot reload: pn run --hot-reload watches app/ and patches edits into the running app on save, preserving component state across most changes.
  • Bundled templates: Android Gradle and iOS Xcode templates are included, so scaffolding requires no network access.

Quick Start

Installation

pip install pythonnative

Usage

import pythonnative as pn


@pn.component
def App():
    count, set_count = pn.use_state(0)
    return pn.Column(
        pn.Text(f"Count: {count}", style=pn.style(font_size=24, bold=True)),
        pn.Button(
            "Tap me",
            on_click=lambda: set_count(count + 1),
        ),
        style=pn.style(spacing=12, padding=16),
    )

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythonnative-0.21.0.tar.gz (431.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pythonnative-0.21.0-py3-none-any.whl (410.3 kB view details)

Uploaded Python 3

File details

Details for the file pythonnative-0.21.0.tar.gz.

File metadata

  • Download URL: pythonnative-0.21.0.tar.gz
  • Upload date:
  • Size: 431.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pythonnative-0.21.0.tar.gz
Algorithm Hash digest
SHA256 3b552ea8ac9454aa0ed04bf55f301e62f7efca7f4c1723096480036c6f012d97
MD5 800bf56bba6a82b8a9244ea00aa3c372
BLAKE2b-256 60ddb45135bb5d08f7b7be9895af15c16890d4a44cba90f4e056a4e055e7e02a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythonnative-0.21.0.tar.gz:

Publisher: release.yml on pythonnative/pythonnative

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pythonnative-0.21.0-py3-none-any.whl.

File metadata

  • Download URL: pythonnative-0.21.0-py3-none-any.whl
  • Upload date:
  • Size: 410.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pythonnative-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22ef567aecab6adfb9d37cfae177b6e1eef03b44950e3d182b6c43c9e60e9a2d
MD5 3da097a10587ad703540232da021bbf4
BLAKE2b-256 97ad7803c8944b910a6898ac3c3609b375f00aa569211ed206b6b7735e22fea7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythonnative-0.21.0-py3-none-any.whl:

Publisher: release.yml on pythonnative/pythonnative

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page