stretchable


Namestretchable JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryLayout library for Python (based on Taffy, a rust-powered implementation of CSS Grid/Flexbox)
upload_time2023-11-25 22:32:01
maintainer
docs_urlNone
authorKenneth Trelborg Vestergaard
requires_python>=3.8
license
keywords flexbox grid block stretch css layout
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # stretchable

[![PyPI - Version](https://img.shields.io/pypi/v/stretchable)](https://pypi.org/project/stretchable/)
![Python Versions](https://img.shields.io/pypi/pyversions/stretchable)
[![License](https://img.shields.io/github/license/mortencombat/stretchable?color=blue)](https://github.com/mortencombat/stretchable/blob/main/LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/mortencombat/stretchable?logo=github)](https://github.com/mortencombat/stretchable/issues)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/mortencombat/stretchable/build-publish.yml?logo=github)](https://github.com/mortencombat/stretchable/actions/workflows/build-publish.yml)
[![Documentation Status](https://readthedocs.org/projects/stretchable/badge/?version=latest)](https://stretchable.readthedocs.io/en/latest/?badge=latest)
[![Test results](https://gist.github.com/mortencombat/901f1f1190ba5aff13164ede9d4c249f/raw/stretchable-tests.svg)](https://github.com/mortencombat/stretchable/actions/workflows/test.yml)
[![Test coverage](https://gist.github.com/mortencombat/b121474745d15f92a295a0bdd7497529/raw/stretchable-coverage.svg)](https://github.com/mortencombat/stretchable/actions/workflows/test.yml)

**stretchable** is a layout library for Python that enables context-agnostic layout operations using [CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) and [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/). Possible uses include UI layouts, page layouts for reports, complex plotting layouts, etc.

It implements Python bindings for [Taffy](https://github.com/dioxuslabs/taffy), an implementation of Grid/Flexbox written in [Rust](https://www.rust-lang.org/). It was originally based on [Stretch](https://vislyhq.github.io/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](https://pypi.org/project/stretchable/). It can be installed using [pip](https://pip.pypa.io/en/stable/):

```console
python -m pip install attrs
```

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

```python
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 child node
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](https://stretchable.readthedocs.io/).

## Contributing

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

### Building

Install Rust with [rustup](https://rustup.rs/) 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 ~650 tests, the majority of which are run using Selenium with the Chrome WebDriver, and the complete test suite can take ~20 minutes to complete. Use `pytest --lf` to only run the last-failed tests.

## License

This work is released under the MIT license. A copy of the license is provided in the [LICENSE](https://github.com/mortencombat/stretchable/blob/main/LICENSE) file.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "stretchable",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "flexbox,grid,block,stretch,css,layout",
    "author": "Kenneth Trelborg Vestergaard",
    "author_email": "",
    "download_url": "",
    "platform": null,
    "description": "# stretchable\r\n\r\n[![PyPI - Version](https://img.shields.io/pypi/v/stretchable)](https://pypi.org/project/stretchable/)\r\n![Python Versions](https://img.shields.io/pypi/pyversions/stretchable)\r\n[![License](https://img.shields.io/github/license/mortencombat/stretchable?color=blue)](https://github.com/mortencombat/stretchable/blob/main/LICENSE)\r\n[![GitHub issues](https://img.shields.io/github/issues/mortencombat/stretchable?logo=github)](https://github.com/mortencombat/stretchable/issues)\r\n[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/mortencombat/stretchable/build-publish.yml?logo=github)](https://github.com/mortencombat/stretchable/actions/workflows/build-publish.yml)\r\n[![Documentation Status](https://readthedocs.org/projects/stretchable/badge/?version=latest)](https://stretchable.readthedocs.io/en/latest/?badge=latest)\r\n[![Test results](https://gist.github.com/mortencombat/901f1f1190ba5aff13164ede9d4c249f/raw/stretchable-tests.svg)](https://github.com/mortencombat/stretchable/actions/workflows/test.yml)\r\n[![Test coverage](https://gist.github.com/mortencombat/b121474745d15f92a295a0bdd7497529/raw/stretchable-coverage.svg)](https://github.com/mortencombat/stretchable/actions/workflows/test.yml)\r\n\r\n**stretchable** is a layout library for Python that enables context-agnostic layout operations using [CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) and [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/). Possible uses include UI layouts, page layouts for reports, complex plotting layouts, etc.\r\n\r\nIt implements Python bindings for [Taffy](https://github.com/dioxuslabs/taffy), an implementation of Grid/Flexbox written in [Rust](https://www.rust-lang.org/). It was originally based on [Stretch](https://vislyhq.github.io/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.\r\n\r\n## Getting Started\r\n\r\n**stretchable** is a Python package [hosted on PyPI](https://pypi.org/project/stretchable/). It can be installed using [pip](https://pip.pypa.io/en/stable/):\r\n\r\n```console\r\npython -m pip install attrs\r\n```\r\n\r\nBuilding a tree of nodes and calculating the layout is as simple as:\r\n\r\n```python\r\nfrom stretchable import Edge, Node\r\nfrom stretchable.style import AUTO, PCT\r\n\r\n# Build node tree\r\nroot = Node(\r\n    margin=20,\r\n    size=(500, 300),\r\n).add(\r\n    Node(border=5, size=(50 * PCT, AUTO)),\r\n    Node(key=\"child\", padding=10 * PCT, size=50 * PCT),\r\n)\r\n\r\n# Compute layout\r\nroot.compute_layout()\r\n\r\n# Get the second child node\r\nchild_node = root.find(\"/child\")\r\ncontent_box = child_node.get_box(Edge.CONTENT)\r\nprint(content_box)\r\n# Box(x=300.0, y=50.0, width=150.0, height=50.0)\r\n\r\n```\r\n\r\nFor more information and details, see the [documentation](https://stretchable.readthedocs.io/).\r\n\r\n## Contributing\r\n\r\nContributions are welcomed. Please open an issue to clarify/plan implementation details prior to starting the work.\r\n\r\n### Building\r\n\r\nInstall Rust with [rustup](https://rustup.rs/) and use `maturin develop` for development and `maturin build [--release]` to build.\r\n\r\n### Documentation\r\n\r\nTo build documentation use `make html` (in `docs/` folder) or, to use live reloading: `sphinx-autobuild docs/source docs/build/html`\r\n\r\nNOTE: Sometimes, you may need to run `make clean html` (in `docs/` folder) to ensure that all changes are included in the built html.\r\n\r\n### Testing\r\n\r\nInstall test dependencies and invoke `pytest`. Note that there are ~650 tests, the majority of which are run using Selenium with the Chrome WebDriver, and the complete test suite can take ~20 minutes to complete. Use `pytest --lf` to only run the last-failed tests.\r\n\r\n## License\r\n\r\nThis work is released under the MIT license. A copy of the license is provided in the [LICENSE](https://github.com/mortencombat/stretchable/blob/main/LICENSE) file.\r\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Layout library for Python (based on Taffy, a rust-powered implementation of CSS Grid/Flexbox)",
    "version": "1.0.0",
    "project_urls": {
        "Documentation": "https://stretchable.readthedocs.io/en/latest/",
        "Homepage": "https://stretchable.readthedocs.io/en/latest/",
        "Source": "https://github.com/mortencombat/stretchable",
        "Tracker": "https://github.com/mortencombat/stretchable/issues"
    },
    "split_keywords": [
        "flexbox",
        "grid",
        "block",
        "stretch",
        "css",
        "layout"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2298b3f15792bb8b08d026b863cb2abcef697b9f5f70d361c5a8b2787b73da2",
                "md5": "ec3b2e2c6152627ec768fbe4394129db",
                "sha256": "59788c98def14e2b7035cdab25b133aa064fb23d58f1e7526f3f5ecef1d9ed1d"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-macosx_10_7_x86_64.whl",
            "has_sig": false,
            "md5_digest": "ec3b2e2c6152627ec768fbe4394129db",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 496687,
            "upload_time": "2023-11-25T22:32:01",
            "upload_time_iso_8601": "2023-11-25T22:32:01.914301Z",
            "url": "https://files.pythonhosted.org/packages/b2/29/8b3f15792bb8b08d026b863cb2abcef697b9f5f70d361c5a8b2787b73da2/stretchable-1.0.0-cp38-abi3-macosx_10_7_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "85d31a1020e73bdcdbc854115430da365c2caeb9f7ea9d286cd1f140006b5ed7",
                "md5": "341bb0c3af4a0b229c52850e2926faf4",
                "sha256": "5c7ce2a9379246820eaf5f3249f29c398f366544f27ef5ad491922878256be80"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "341bb0c3af4a0b229c52850e2926faf4",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 456954,
            "upload_time": "2023-11-25T22:32:07",
            "upload_time_iso_8601": "2023-11-25T22:32:07.020407Z",
            "url": "https://files.pythonhosted.org/packages/85/d3/1a1020e73bdcdbc854115430da365c2caeb9f7ea9d286cd1f140006b5ed7/stretchable-1.0.0-cp38-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90e85e06a4c9c7c6b1d9b16998969701ecfa5999a15f3721df29b20bde97b674",
                "md5": "a358e909b58905482502aadeab12e9c8",
                "sha256": "22d63abf1b6e802071aaefd23cd40e4d930e4ce9aa770bcc4bda6ee04fcf032b"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "a358e909b58905482502aadeab12e9c8",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1361990,
            "upload_time": "2023-11-25T22:32:09",
            "upload_time_iso_8601": "2023-11-25T22:32:09.048785Z",
            "url": "https://files.pythonhosted.org/packages/90/e8/5e06a4c9c7c6b1d9b16998969701ecfa5999a15f3721df29b20bde97b674/stretchable-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29f56523a0e715415297f046f90b6cb127e912149b45e6a3caea3e05c728272c",
                "md5": "53f697790ce1e04e2a516dcf374dfdc0",
                "sha256": "eb68382ed2b73749bab1e1b7538250b543fa6e6c4988fe3c00feb49c07cd7c74"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "53f697790ce1e04e2a516dcf374dfdc0",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1385985,
            "upload_time": "2023-11-25T22:32:11",
            "upload_time_iso_8601": "2023-11-25T22:32:11.113695Z",
            "url": "https://files.pythonhosted.org/packages/29/f5/6523a0e715415297f046f90b6cb127e912149b45e6a3caea3e05c728272c/stretchable-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6f7a3d3d07a3b9dfd1ac107731a0405cdb3fbecf892838159d260eea85fae41",
                "md5": "77d7400095ca3a218846b907a13c1534",
                "sha256": "31b394447f159232b431df75f8013c872ab83824d5366034406010498cfd9eb1"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-musllinux_1_2_aarch64.whl",
            "has_sig": false,
            "md5_digest": "77d7400095ca3a218846b907a13c1534",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1537909,
            "upload_time": "2023-11-25T22:32:13",
            "upload_time_iso_8601": "2023-11-25T22:32:13.270408Z",
            "url": "https://files.pythonhosted.org/packages/d6/f7/a3d3d07a3b9dfd1ac107731a0405cdb3fbecf892838159d260eea85fae41/stretchable-1.0.0-cp38-abi3-musllinux_1_2_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6cbab0302db5ba9a4035ed671b6084c6b958c2440fc4c95856bc496fe0052a2d",
                "md5": "b65fd05a4c3e7d0abb485605eb4aa531",
                "sha256": "264df60aa8b3dab755c0c94cc7f81d30443df00686785c12b3b41e3a8c25fdb7"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-musllinux_1_2_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b65fd05a4c3e7d0abb485605eb4aa531",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1560493,
            "upload_time": "2023-11-25T22:32:15",
            "upload_time_iso_8601": "2023-11-25T22:32:15.547679Z",
            "url": "https://files.pythonhosted.org/packages/6c/ba/b0302db5ba9a4035ed671b6084c6b958c2440fc4c95856bc496fe0052a2d/stretchable-1.0.0-cp38-abi3-musllinux_1_2_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d2d268fc16238ee2271d446d482f864c0cb6ac1a979bb5b13fa0d1cd7ac40792",
                "md5": "aece1432fbafa2d841e6ff30f5136dee",
                "sha256": "bfa075ff1c4bb24f48f5952783578bbe330414ea9817defad75bb25e355d4a06"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-win32.whl",
            "has_sig": false,
            "md5_digest": "aece1432fbafa2d841e6ff30f5136dee",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 292419,
            "upload_time": "2023-11-25T22:32:16",
            "upload_time_iso_8601": "2023-11-25T22:32:16.933183Z",
            "url": "https://files.pythonhosted.org/packages/d2/d2/68fc16238ee2271d446d482f864c0cb6ac1a979bb5b13fa0d1cd7ac40792/stretchable-1.0.0-cp38-abi3-win32.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d3f1d631dcca4b6eaeb854573bfb1f94f1a13eda369c500bfc68995f38529cc",
                "md5": "cd3383f5645a839293f7bdbb0a4ffef7",
                "sha256": "8342938e5be023a59cd03e877aa726c9ba4824ff7f36b08be8fd2269e1bea575"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "cd3383f5645a839293f7bdbb0a4ffef7",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 332079,
            "upload_time": "2023-11-25T22:32:18",
            "upload_time_iso_8601": "2023-11-25T22:32:18.683706Z",
            "url": "https://files.pythonhosted.org/packages/0d/3f/1d631dcca4b6eaeb854573bfb1f94f1a13eda369c500bfc68995f38529cc/stretchable-1.0.0-cp38-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "100aea5d74558478e20117f5503f80736375f5f5c52f2d542feaa198a97ca35d",
                "md5": "094019de67699cf3fc860fc5a4f0294c",
                "sha256": "f9c2706e6dddf98f4037b6ac11717fb287806ff0ff51fe2650b6bdd0afb7bdb6"
            },
            "downloads": -1,
            "filename": "stretchable-1.0.0-cp38-abi3-win_arm64.whl",
            "has_sig": false,
            "md5_digest": "094019de67699cf3fc860fc5a4f0294c",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 306895,
            "upload_time": "2023-11-25T22:32:19",
            "upload_time_iso_8601": "2023-11-25T22:32:19.921240Z",
            "url": "https://files.pythonhosted.org/packages/10/0a/ea5d74558478e20117f5503f80736375f5f5c52f2d542feaa198a97ca35d/stretchable-1.0.0-cp38-abi3-win_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-25 22:32:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mortencombat",
    "github_project": "stretchable",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stretchable"
}
        
Elapsed time: 0.14325s