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 Pythonic API for native UI components, lifecycle events, and device capabilities, powered by Chaquopy on Android and rubicon-objc on iOS. Write your app once in Python and run it on both platforms with genuinely native interfaces.

Features

  • Cross-platform native UI: Build Android and iOS apps from a single Python codebase with truly native rendering.
  • Direct native bindings: Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
  • Unified component API: Components like Page, StackView, Label, Button, and WebView share a consistent interface across platforms.
  • CLI scaffolding: pn init creates a ready-to-run project structure; pn run android and pn run ios build and launch your app.
  • Page lifecycle: Hooks for on_create, on_start, on_resume, on_pause, on_stop, and on_destroy, with state save and restore.
  • Navigation: Push and pop screens with argument passing for multi-page apps.
  • Rich component set: Core views (Label, Button, TextField, ImageView, WebView, Switch, DatePicker, and more) plus Material Design variants.
  • 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


class MainPage(pn.Page):
    def __init__(self, native_instance):
        super().__init__(native_instance)

    def on_create(self):
        super().on_create()
        stack = pn.StackView()
        stack.add_view(pn.Label("Hello from PythonNative!"))
        button = pn.Button("Tap me")
        button.set_on_click(lambda: print("Button tapped"))
        stack.add_view(button)
        self.set_root_view(stack)

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