Skip to main content

Layout library for Python (based on Taffy, a rust-powered implementation of CSS Grid/Flexbox)

Project description

stretchable

PyPI - Version Python Versions License GitHub issues GitHub Workflow Status (with event) Documentation Status Test results Test coverage

stretchable is a layout library for Python that enables context-agnostic layout operations using CSS Block, CSS Grid and Flexbox. Possible uses include UI layouts, page layouts for reports, complex plotting layouts, etc.

It implements Python bindings for Taffy, an implementation of CSS Block, Flexbox and CSS Grid layout algorithms written in Rust. It was originally based on Stretch (hence the name), but has since migrated to use Taffy. It is multi-platform and there are distributions available for Windows, Linux and macOS.

Getting Started

stretchable is a Python package hosted on PyPI. It can be installed using pip:

python -m pip install stretchable

Building a tree of nodes and calculating the layout is as simple as:

from stretchable import Edge, Node
from stretchable.style import AUTO, PCT

# Build node tree
root = Node(
    margin=20,
    size=(500, 300),
).add(
    Node(border=5, size=(50 * PCT, AUTO)),
    Node(key="child", padding=10 * PCT, size=50 * PCT),
)

# Compute layout
root.compute_layout()

# Get the second of the child nodes
child_node = root.find("/child")
content_box = child_node.get_box(Edge.CONTENT)
print(content_box)
# Box(x=300.0, y=50.0, width=150.0, height=50.0)

For more information and details, see the documentation.

Contributing

Contributions are welcomed. Please open an issue to clarify/plan implementation details prior to starting the work.

Building

Install Rust with rustup and use maturin develop for development and maturin build [--release] to build.

Documentation

To build documentation use make html (in docs/ folder) or, to use live reloading: sphinx-autobuild docs/source docs/build/html

NOTE: Sometimes, you may need to run make clean html (in docs/ folder) to ensure that all changes are included in the built html.

Testing

Install test dependencies and invoke pytest. Note that there are ~900 tests, the majority of which are run using Selenium with the Chrome WebDriver, and the complete test suite can take ~30 minutes to complete. Use pytest --lf to only run the last-failed tests.

To run basic tests and ensure compatibility with a specific Python version, use Docker and the provided Dockerfile: docker build . [--build-arg pyver=3.11] (defaults to lowest supported Python version, currently 3.8).

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

stretchable-1.1.8-cp38-abi3-win_arm64.whl (334.6 kB view details)

Uploaded CPython 3.8+Windows ARM64

stretchable-1.1.8-cp38-abi3-win_amd64.whl (356.8 kB view details)

Uploaded CPython 3.8+Windows x86-64

stretchable-1.1.8-cp38-abi3-win32.whl (347.4 kB view details)

Uploaded CPython 3.8+Windows x86

stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl (697.1 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl (686.4 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (530.1 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (506.2 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl (468.0 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl (486.7 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file stretchable-1.1.8-cp38-abi3-win_arm64.whl.

File metadata

  • Download URL: stretchable-1.1.8-cp38-abi3-win_arm64.whl
  • Upload date:
  • Size: 334.6 kB
  • Tags: CPython 3.8+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 fec7556c160f73bd200af15570e6d219612499760172cb3485680e1286a7a316
MD5 6f93027e5011afb4b5d57b19abc26d63
BLAKE2b-256 b86899d5ccda98a60954095f60a49287384d1105cc2ee1d0fec7692f72e549b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-win_arm64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: stretchable-1.1.8-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 356.8 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 42c10d864b3e8b2cb0ce16a64df6905318c6a78c6269041b1532c606bf6158c3
MD5 5d86951c4599c41c62533063b0474d60
BLAKE2b-256 9382f632174499bf13fec72e58872d1df56abedb8ab36b9a9c4d2940f73a5f0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-win_amd64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-win32.whl.

File metadata

  • Download URL: stretchable-1.1.8-cp38-abi3-win32.whl
  • Upload date:
  • Size: 347.4 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 642c8025ec7ea12d37a66fb4cdd5619513efc6f1617cf1cafdb01d49c18a2dc3
MD5 3c28e21b5285a53cae57b95c2412b091
BLAKE2b-256 a999e58bb54055265fb01e387d414c33a62733821290cfa266509edb21d6446b

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-win32.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b031ba4e400599c87ffcb9cd818f3939db6f5434aae49533481842939d507ba8
MD5 9e3dbe034d1a0a6852ce2e8a0254b855
BLAKE2b-256 13b6008bebdd0edbb320bc50a1cee93db1fb527b4381005ed3bed08c00d7bbe5

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-musllinux_1_2_x86_64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7379be3622844bea7356fab3c83b0b46c10b3b8f5cabc7b2071134f7169c1226
MD5 7c765c3d9614275195f8aba87589eb0b
BLAKE2b-256 c5fe5201813989cf8c1c21692ac5afd1a2d36e11741325a46fd6bb1a768452f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-musllinux_1_2_aarch64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1710c748f49c969fb067679847b371f49c1bc9923477a4f8d209029aee485809
MD5 5ed53f322e86f97db0e4e79c0d31803a
BLAKE2b-256 c8b6bf0bff56102d87f16cf953bf1bef64fd7682fa1533bea9fc42f2e863a9c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 173b02e696763d1a1b922c9930d55740940c4a22290e11ae564a7574d175c54b
MD5 149341c03aa04d1069d145cb86bc226e
BLAKE2b-256 0d0b7b3fbb028d6e82d624b72f9f3cae6a2fd753c994b405d479338a0f0da073

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9160a4013a1e37bd4c5dd4a6ea252cec2923cc91ba6bd68b20e7a1a8bfee8be
MD5 713aec5366c62ec9e363313835bd1471
BLAKE2b-256 6c4dadd8d6cbf3d64dc1ecc2e57d803063d618b623919391f07dd80b06710d40

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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

File details

Details for the file stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e34e7988129b877bed1f9a247deed174ffed8066ab5b9a3178f18f1102836468
MD5 81f4596f47b39cea3429f601e1586ddd
BLAKE2b-256 5ea3e4c2b5420e4618550ea3153cd55921564c87aeb9206007c972c6512334dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for stretchable-1.1.8-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: build-publish.yml on mortencombat/stretchable

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