cell height now dynamic in tables
This commit is contained in:
@@ -371,6 +371,59 @@ def demo_performance_optimization():
|
||||
print()
|
||||
|
||||
|
||||
def create_animated_gif():
|
||||
"""
|
||||
Create an animated GIF showing the button press sequence.
|
||||
"""
|
||||
from PIL import Image
|
||||
import os
|
||||
|
||||
print("=" * 70)
|
||||
print("Creating Animated GIF")
|
||||
print("=" * 70)
|
||||
print()
|
||||
|
||||
# Check if the PNG files exist
|
||||
png_files = [
|
||||
"demo_07_initial.png",
|
||||
"demo_07_pressed.png",
|
||||
"demo_07_released.png"
|
||||
]
|
||||
|
||||
if not all(os.path.exists(f) for f in png_files):
|
||||
print(" ⚠ PNG files not found, skipping GIF creation")
|
||||
return
|
||||
|
||||
# Load the images
|
||||
initial = Image.open('demo_07_initial.png')
|
||||
pressed = Image.open('demo_07_pressed.png')
|
||||
released = Image.open('demo_07_released.png')
|
||||
|
||||
# Create animated GIF showing the button interaction sequence
|
||||
# Sequence: initial (1000ms) -> pressed (200ms) -> released (500ms) -> loop
|
||||
frames = [initial, pressed, released]
|
||||
durations = [1000, 200, 500] # milliseconds per frame
|
||||
|
||||
output_path = "docs/images/example_07_button_animation.gif"
|
||||
|
||||
# Create docs/images directory if it doesn't exist
|
||||
os.makedirs("docs/images", exist_ok=True)
|
||||
|
||||
# Save as animated GIF
|
||||
initial.save(
|
||||
output_path,
|
||||
save_all=True,
|
||||
append_images=[pressed, released],
|
||||
duration=durations,
|
||||
loop=0 # 0 means loop forever
|
||||
)
|
||||
|
||||
print(f" ✓ Created: {output_path}")
|
||||
print(f" ✓ Frames: {len(frames)}")
|
||||
print(f" ✓ Sequence: initial (1000ms) → pressed (200ms) → released (500ms)")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("\n")
|
||||
print("╔" + "═" * 68 + "╗")
|
||||
@@ -391,6 +444,9 @@ if __name__ == "__main__":
|
||||
demo_performance_optimization()
|
||||
print("\n")
|
||||
|
||||
# Create animated GIF
|
||||
create_animated_gif()
|
||||
|
||||
print("=" * 70)
|
||||
print("All demos complete! Check the generated PNG files.")
|
||||
print("All demos complete! Check the generated PNG files and animated GIF.")
|
||||
print("=" * 70)
|
||||
|
||||
+73
-29
@@ -68,10 +68,10 @@ Demonstrates:
|
||||

|
||||
|
||||
### 05. Tables with Images
|
||||
**`05_table_with_images.py`** - Tables containing images and mixed content
|
||||
**`05_html_table_with_images.py`** - Tables containing images and mixed content
|
||||
|
||||
```bash
|
||||
python 05_table_with_images.py
|
||||
python 05_html_table_with_images.py
|
||||
```
|
||||
|
||||
Demonstrates:
|
||||
@@ -80,8 +80,9 @@ Demonstrates:
|
||||
- Book catalog and product showcase tables
|
||||
- Mixed content (images and text) in cells
|
||||
- Using cover images from test data
|
||||
- HTML table parsing with `<img>` tags
|
||||
|
||||

|
||||

|
||||
|
||||
### 06. Functional Elements (Interactive)
|
||||
**`06_functional_elements_demo.py`** - Interactive buttons and forms with callbacks
|
||||
@@ -101,13 +102,47 @@ Demonstrates:
|
||||
|
||||

|
||||
|
||||
### 07. Button Pressed States (Interactive)
|
||||
**`07_pressed_state_demo.py`** - Visual feedback for button interactions
|
||||
|
||||
```bash
|
||||
python 07_pressed_state_demo.py
|
||||
```
|
||||
|
||||
Demonstrates:
|
||||
- Button pressed/released state management
|
||||
- Visual feedback timing (150ms press duration)
|
||||
- Automatic interaction handling with `InteractionHandler`
|
||||
- Manual state management for custom event loops
|
||||
- Dirty flag system for optimized re-rendering
|
||||
- State tracking with `InteractionStateManager`
|
||||
|
||||

|
||||
|
||||
*Animated GIF showing button press sequence: initial → pressed → released*
|
||||
|
||||
---
|
||||
|
||||
## 🆕 New Examples (2024-11)
|
||||
|
||||
These examples address critical coverage gaps and demonstrate advanced features:
|
||||
|
||||
### 08. Pagination with PageBreak (NEW) ✅
|
||||
### 08. Bundled Fonts Showcase
|
||||
**`08_bundled_fonts_demo.py`** - Demonstration of all bundled fonts
|
||||
|
||||
```bash
|
||||
python 08_bundled_fonts_demo.py
|
||||
```
|
||||
|
||||
Demonstrates:
|
||||
- DejaVu Sans (Sans-serif)
|
||||
- DejaVu Serif (Serif)
|
||||
- DejaVu Sans Mono (Monospace)
|
||||
- All font variants: Regular, Bold, Italic, Bold Italic
|
||||
|
||||

|
||||
|
||||
### 08. Pagination with PageBreak ✅
|
||||
**`08_pagination_demo.py`** - Multi-page documents with explicit and automatic pagination
|
||||
|
||||
```bash
|
||||
@@ -201,18 +236,6 @@ Demonstrates:
|
||||
|
||||
---
|
||||
|
||||
## Advanced Examples
|
||||
|
||||
### HTML Rendering
|
||||
|
||||
These examples demonstrate rendering HTML content to multi-page layouts:
|
||||
|
||||
**`html_line_breaking_demo.py`** - Basic HTML line breaking demonstration
|
||||
**`html_multipage_simple.py`** - Simple single-page HTML rendering
|
||||
**`html_multipage_demo_final.py`** - Complete multi-page HTML rendering with headers/footers
|
||||
|
||||
For detailed information about HTML rendering, see `README_HTML_MULTIPAGE.md`.
|
||||
|
||||
## Running the Examples
|
||||
|
||||
All examples can be run directly from the examples directory:
|
||||
@@ -220,24 +243,45 @@ All examples can be run directly from the examples directory:
|
||||
```bash
|
||||
cd examples
|
||||
|
||||
# Getting Started
|
||||
python 01_simple_page_rendering.py
|
||||
python 02_text_and_layout.py
|
||||
python 03_page_layouts.py
|
||||
python 04_table_rendering.py
|
||||
python 05_table_with_images.py
|
||||
python 06_functional_elements_demo.py
|
||||
# Getting Started (01-07)
|
||||
python 01_simple_page_rendering.py # Page layouts
|
||||
python 02_text_and_layout.py # Text alignment with justified text
|
||||
python 03_page_layouts.py # Various page sizes
|
||||
python 04_table_rendering.py # Table styles
|
||||
python 05_html_table_with_images.py # HTML tables with images
|
||||
python 06_functional_elements_demo.py # Interactive buttons and forms
|
||||
python 07_pressed_state_demo.py # Button pressed states (generates GIF)
|
||||
|
||||
# NEW: Advanced Features
|
||||
python 08_pagination_demo.py # Multi-page documents
|
||||
python 09_link_navigation_demo.py # All link types
|
||||
python 10_forms_demo.py # All form field types
|
||||
python 11_table_text_wrapping_demo.py # Table cell text wrapping
|
||||
python 11b_simple_table_wrapping.py # Simple wrapping demo
|
||||
# Advanced Features (08-11)
|
||||
python 08_bundled_fonts_demo.py # Bundled font showcase
|
||||
python 08_pagination_demo.py # Multi-page documents
|
||||
python 09_link_navigation_demo.py # All link types
|
||||
python 10_forms_demo.py # All form field types
|
||||
python 11_table_text_wrapping_demo.py # Table text wrapping
|
||||
python 11b_simple_table_wrapping.py # Simple wrapping demo
|
||||
```
|
||||
|
||||
Output images are saved to the `docs/images/` directory.
|
||||
|
||||
## Recent Improvements
|
||||
|
||||
### ✅ Justified Text Fix (2024-11-10)
|
||||
Lines using justified alignment now properly fill the entire width by:
|
||||
- Calculating base spacing and remainder pixels
|
||||
- Distributing remainder across word gaps to eliminate short lines
|
||||
- Removing max_spacing constraint for true justification
|
||||
|
||||
**Affected examples:** 02, 11, 11b - All text now perfectly justified!
|
||||
|
||||
### ✅ Animated Button States (2024-11-10)
|
||||
Example 07 now automatically generates an animated GIF showing button interactions:
|
||||
- Initial state (1000ms)
|
||||
- Pressed state (200ms)
|
||||
- Released state (500ms)
|
||||
- Loops continuously
|
||||
|
||||
**Output:** `docs/images/example_07_button_animation.gif`
|
||||
|
||||
### Running Tests
|
||||
|
||||
All new examples (08, 09, 10) include comprehensive test coverage:
|
||||
|
||||
Reference in New Issue
Block a user