Duncan Tourolle cfd8678af5
All checks were successful
Python CI / test (push) Successful in 43s
coerage report
2025-06-07 17:33:11 +02:00
2025-06-07 16:59:42 +02:00
2025-06-07 17:11:22 +02:00
2025-06-07 17:11:22 +02:00
2025-06-07 17:33:11 +02:00
2025-06-07 17:33:11 +02:00
2025-05-27 11:58:19 +02:00
2025-06-07 15:12:10 +00:00
2025-06-07 17:33:11 +02:00
2025-05-27 11:58:19 +02:00
2025-05-27 11:58:19 +02:00
2025-06-07 17:33:11 +02:00
2025-06-07 16:55:03 +02:00
2025-06-07 17:11:22 +02:00
2025-05-27 11:58:19 +02:00
2025-05-27 11:58:19 +02:00

PyWebLayout

Project Status

Badge Description
Test Coverage Test Coverage - Percentage of code covered by unit tests
Documentation Coverage Documentation Coverage - Percentage of code with docstrings
License License - Project licensing information
A Python library for HTML-like layout and rendering.

📋 Note: Badges show results from the commit referenced in the URLs. Red "error" badges indicate build failures for that specific step.

Description

PyWebLayout provides classes for rendering HTML-like content to images using a box-based layout system. It includes support for text, tables, and containers, as well as an HTML parser for converting HTML to layout objects.

Features

  • HTML-like layout system
  • Text rendering with font support
  • Table layouts
  • Container elements
  • HTML parsing
  • Image output

Installation

pip install pyWebLayout

Usage

Basic Example

from pyWebLayout.concrete.page import Page, Container
from pyWebLayout.abstract.inline import Line
from pyWebLayout.layout import Alignment
from PIL import ImageFont

# Create a page
page = Page(size=(800, 600), background_color=(240, 240, 240))

# Add a title container
title_container = Container(
    origin=(0, 0),
    size=(780, 60),
    direction='horizontal',
    spacing=10,
    padding=(10, 10, 10, 10),
    halign=Alignment.CENTER,
    valign=Alignment.CENTER
)
page.add_child(title_container)

# Create a title line with text
title_font = ImageFont.load_default()
title_line = Line(
    spacing=(8, 15),
    origin=(0, 0),
    size=(760, 40),
    font=title_font,
    text_color=(0, 0, 0),
    halign=Alignment.CENTER
)
title_container.add_child(title_line)
title_line.add_word("PyWebLayout", title_font)
title_line.add_word("Example", title_font)

# Layout and render the page
page.layout()
image = page.render()
image.save("example.png")

HTML Example

from pyWebLayout.html_parser import html_to_image

html = """
<div style="text-align: center; padding: 10px;">
    <h1>PyWebLayout HTML Example</h1>
    <p>This is a paragraph rendered from HTML.</p>
    <p>The library supports <b>bold</b>, <i>italic</i>, and <u>underlined</u> text.</p>
</div>
"""

# Render HTML to an image
image = html_to_image(html, page_size=(800, 600))
image.save("html_example.png")

License

MIT License

Author

Duncan Tourolle - duncan@tourolle.paris

Description
No description provided
Readme MIT 50 MiB
Languages
Python 100%