pyWebLayout/simple_test.py
Duncan Tourolle 8d892bfe28
Some checks failed
Python CI / test (push) Failing after 4m28s
New alignement handlers
2025-06-08 14:08:29 +02:00

39 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Simple test to check if the refactored text alignment system works.
"""
try:
from pyWebLayout.concrete.text import Line, Text, AlignmentHandler, LeftAlignmentHandler
from pyWebLayout.style.layout import Alignment
from pyWebLayout.style import Font
print("✓ All imports successful")
# Create a simple font
font = Font()
print("✓ Font created")
# Create a line with left alignment
line = Line((5, 20), (0, 0), (200, 30), font, halign=Alignment.LEFT)
print("✓ Line created with left alignment")
print(f" Handler type: {type(line._alignment_handler).__name__}")
# Try adding a word
result = line.add_word("Hello")
print(f"✓ Added word 'Hello', result: {result}")
print(f" Line now has {len(line.text_objects)} text objects")
# Test different alignments
alignments = [Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.JUSTIFY]
for align in alignments:
test_line = Line((5, 20), (0, 0), (200, 30), font, halign=align)
handler_name = type(test_line._alignment_handler).__name__
print(f"{align.name} alignment uses {handler_name}")
print("✓ All tests passed!")
except Exception as e:
print(f"✗ Error: {e}")
import traceback
traceback.print_exc()