
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Layout library for Python (based on Taffy, a rust-powered implementation of CSS Grid/Flexbox)
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.
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.
Contributions are welcomed. Please open an issue to clarify/plan implementation details prior to starting the work.
Install Rust with rustup and use maturin develop
for development and maturin build [--release]
to build.
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.
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).
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.
FAQs
Layout library for Python (based on Taffy, a rust-powered implementation of CSS Grid/Flexbox)
We found that stretchable demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.