auto flake and corrections

This commit is contained in:
2025-11-08 23:46:15 +01:00
parent 1ea870eef5
commit 781a9b6c08
81 changed files with 4646 additions and 3718 deletions
+30 -11
View File
@@ -11,6 +11,8 @@ This example demonstrates:
This is a foundational example showing the basic Page API.
"""
from pyWebLayout.style.page_style import PageStyle
from pyWebLayout.concrete.page import Page
import sys
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
@@ -18,9 +20,6 @@ from PIL import Image, ImageDraw, ImageFont
# Add pyWebLayout to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from pyWebLayout.concrete.page import Page
from pyWebLayout.style.page_style import PageStyle
def draw_placeholder_content(page: Page):
"""Draw some placeholder content directly on the page to visualize the layout."""
@@ -46,13 +45,32 @@ def draw_placeholder_content(page: Page):
# Add some text labels
try:
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 12)
except:
except BaseException:
font = ImageFont.load_default()
# Label the areas
draw.text((content_x + 10, content_y + 10), "Content Area", fill=(100, 100, 100), font=font)
draw.text((10, 10), f"Border: {page.border_size}px", fill=(150, 150, 150), font=font)
draw.text((content_x + 10, content_y + 30), f"Size: {content_w}x{content_h}", fill=(100, 100, 100), font=font)
draw.text(
(content_x + 10,
content_y + 10),
"Content Area",
fill=(
100,
100,
100),
font=font)
draw.text(
(10, 10), f"Border: {
page.border_size}px", fill=(
150, 150, 150), font=font)
draw.text(
(content_x + 10,
content_y + 30),
f"Size: {content_w}x{content_h}",
fill=(
100,
100,
100),
font=font)
def create_example_1():
@@ -117,7 +135,7 @@ def create_example_4():
def combine_into_grid(pages, title):
"""Combine multiple pages into a 2x2 grid with title."""
print(f"\n Combining pages into grid...")
print("\n Combining pages into grid...")
# Render all pages
images = [page.render() for page in pages]
@@ -141,8 +159,9 @@ def combine_into_grid(pages, title):
# Draw title
try:
title_font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 20)
except:
title_font = ImageFont.truetype(
"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 20)
except BaseException:
title_font = ImageFont.load_default()
# Center the title
@@ -187,7 +206,7 @@ def main():
output_path = output_dir / "example_01_page_rendering.png"
combined_image.save(output_path)
print(f"\n✓ Example completed!")
print("\n✓ Example completed!")
print(f" Output saved to: {output_path}")
print(f" Image size: {combined_image.size[0]}x{combined_image.size[1]} pixels")
print(f" Created {len(pages)} page examples")