Package overview¶
PythonNative re-exports a small public surface from
pythonnative/__init__.py. Most user code only ever touches the names
in this overview; deeper internals (reconciler, native_views,
hosts) are documented for contributors and integrators.
Entry point¶
Your app module defines a top-level component named App:
The bundled Android ScreenFragment and iOS ViewController load
your app by module path ("app.main") and look up the
module's top-level App attribute. There is no registration step
or imperative bootstrap call. If you need to expose a
differently-named root component, configure the templates to load
an explicit dotted path like "app.main.RootScreen" instead.
PythonNative: declarative native UI for Android and iOS.
PythonNative is a cross-platform toolkit that turns Python @component
functions into real, native Android and iOS views. The component model
is React-like (function components plus hooks). Python owns the logical
component tree and reconciliation on a dedicated asyncio application thread.
Versioned commits cross into Swift PythonNativeKit on iOS and the Kotlin
pythonnative module on Android. Those renderers own widgets, Yoga layout,
measurement, gestures, and animation frames on the platform UI thread.
The browser preview uses DOM widgets and Yoga WebAssembly.
Key building blocks:
- Element factories (
Text,Button,Column, etc.) return immutableElementdescriptors. - Hooks (
use_state,use_effect,use_reducer, etc.) manage state, side effects, and context inside@componentfunctions. - Navigation is built from
NavigationContainerplus one of thecreate_stack_navigator,create_tab_navigator, orcreate_drawer_navigatorfactories. - Styling uses a single
styledict per element (or a list of dicts), composable viaStyleSheet. PythonNative ships a fully-typedStyleTypedDict so editors andmypyvalidate every key as you type. - Animations use the
Animatednamespace. Serialized graphs connect values, arithmetic, interpolation, and style bindings. Native timing, spring, decay, scroll, and gesture drivers update supported bindings without Python work on every frame. - Gestures attach to any view via the
gestures=prop using descriptors frompythonnative.gestures(Tap,LongPress,Pan,Swipe,Pinch,Rotation). - Custom native components can be authored with the
pythonnative.sdkpackage: define a typedPropsdataclass, implement aViewHandlerfor each platform, and register it via@native_component(or expose it from a PyPI package via thepythonnative.handlersentry-point group).
Example
Where to look next¶
The reference is split per module so each page stays scannable:
Property reference¶
All visual and layout properties pass through the style dict (or a
list of dicts). The full per-component property catalogue lives in
Component properties.