Skip to main content

nativelayout

Describe a screen in HTML-like text and get a native interface.

nativelayout is a declarative language for user interfaces.

You write a screen once, in a plain text file (.nl) that looks like HTML, and each programming language shows it with its own host. There is no WebView.

A .nl file has:

  • HTML tags you already know (div, p, button, input, img, ...);
  • {values} that your code fills in;
  • if and for lines, for conditions and repetition;
  • a <style> with simple CSS selectors.

The file only describes the screen. The logic (state and taps) stays in your own code, in a screen function.

nativelayout is a specification with implementations: Kotlin for Android, Python (this package) and JavaScript (used by the online editor). The same .nl file works unchanged in all of them.

This package is the Python implementation: a pure Python core (parser, expander, layout engine and differ) and a Kivy host that draws the screen.

Install

pip install nativelayout            # core only, pure Python, no dependencies
pip install "nativelayout[kivy]"    # core + Kivy host

Python 3.10 or newer. The host needs Kivy 2.x. On Android, package the app with buildozer (requirements = python3,kivy,nativelayout).

Example

screen.nl:

<nativelayout>
<style>
body { padding: 16px; gap: 12px; }
.mais { background-color: #2F81F7; color: white; border-radius: 20px; }
</style>
<body>
<h1>Hello, {name}</h1>
<p>Total: {n}</p>
<button class="mais">+ add</button>
</body>
</nativelayout>

main.py:

import kivy  # noqa: F401  (only needed in Pydroid)
import nativelayout as nl

def screen():
    s = nl.state({"n": 0, "name": "world"})
    if nl.click(".mais"):
        s["n"] += 1
    return nl.view("screen.nl", s)

nl.run(screen)

The file describes the screen. The logic (state and taps) stays in your Python code, in a screen function.

What is in the package

  • nativelayout.core: parser, expander, layout engine, differ and the program side (state, view, click, go, value, save, ...). Pure Python.
  • nativelayout.host: the Kivy host. It draws on a canvas; it does not build platform-native views.

One import is enough: import nativelayout as nl gives the verbs of the core (nl.state, nl.view, nl.click, nl.go, ...) and nl.run(screen), which opens the window and reads the .nl files from the folder of your script (pass folder to change it). from nativelayout import state, view, ... also works. The Kivy host is loaded only when you use one of its names (run, run_app, file_loader, NativeView), so the core works without Kivy. The sub-packages nativelayout.core and nativelayout.host can still be imported directly.

In Pydroid, the file you open must contain import kivy itself; otherwise Pydroid does not start the Kivy window.

Guide

The verbs, several screens, dialogs, storage, images and the status of the host are in the Python guide.

License

Mozilla Public License 2.0. Copyright (c) 2026 Adilson C. Rafael.

Metadata

Release files for nativelayout 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nativelayout 1.2.3
File Size Uploaded Provenance
nativelayout-1.2.3.tar.gz 66.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nativelayout 1.2.3
File Interpreter ABI Platform
nativelayout-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 138.1 kB

Release files / nativelayout-1.2.3.tar.gz

Download URL nativelayout-1.2.3.tar.gz
Size 66.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4b76a703ca720b5d99f4fc7a3fe5a544937a5923e879acf0cf6ad61343e4562b
BLAKE2b-256 checksum
How to use checksums
1f84aeac37ee32abb758c3b47fa1a7ba151dedaad8a73f33fe5cf21c78596ed6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / nativelayout-1.2.3-py3-none-any.whl

Download URL nativelayout-1.2.3-py3-none-any.whl
Size 71.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b502283be526ca3cc7277dd954466eb9c5c44ac4f496db06248c2bf211f6579e
BLAKE2b-256 checksum
How to use checksums
f30f28ae7eda94314341e00e7bd5f21fc9995938e868ef20658a7585c2fe14a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for nativelayout 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nativelayout-1.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page