pyWebLayout/examples/README.md
Duncan Tourolle e6c17ef8a8
All checks were successful
Python CI / test (push) Successful in 7m51s
updating viewport
2025-11-04 23:34:23 +01:00

87 lines
2.6 KiB
Markdown

# PyWebLayout Examples
This directory contains example scripts demonstrating the pyWebLayout library.
## EbookReader Examples
The EbookReader provides a high-level, user-friendly API for building ebook reader applications.
### Quick Start Example
**`simple_ereader_example.py`** - Simple example showing basic EbookReader usage:
```bash
python simple_ereader_example.py path/to/book.epub
```
This demonstrates:
- Loading an EPUB file
- Rendering pages to images
- Basic navigation (next/previous page)
- Saving positions
- Chapter navigation
- Font size adjustment
### Comprehensive Demo
**`ereader_demo.py`** - Full feature demonstration:
```bash
python ereader_demo.py path/to/book.epub
```
This showcases all EbookReader features:
- Page navigation (forward/backward)
- Position save/load with bookmarks
- Chapter navigation (by index or title)
- Font size control
- Line and block spacing adjustments
- Reading progress tracking
- Book information retrieval
**Tip:** You can use the test EPUB files in `tests/data/` for testing:
```bash
python simple_ereader_example.py tests/data/test.epub
python ereader_demo.py tests/data/test.epub
```
## Browser Examples
### HTML Browser with Viewport System
**`html_browser_with_viewport.py`** (located in `pyWebLayout/examples/`) - Full-featured HTML browser using the viewport system:
```bash
python pyWebLayout/examples/html_browser_with_viewport.py
```
This demonstrates:
- Viewport-based scrolling (mouse wheel, keyboard, scrollbar)
- Efficient rendering of large documents
- Text selection and clipboard support
- Navigation and history management
- Interactive HTML viewing
For detailed information about the viewport system, see `README_BROWSER_VIEWPORT.md`.
## Other 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.py`** - Multi-page HTML layout
**`html_multipage_demo_final.py`** - Complete multi-page HTML rendering with headers/footers
For detailed information about HTML rendering, see `README_HTML_MULTIPAGE.md`.
## Documentation
- `README_EREADER.md` - Detailed EbookReader API documentation
- `README_HTML_MULTIPAGE.md` - HTML multi-page rendering guide
- `README_BROWSER_VIEWPORT.md` - Browser viewport system documentation
- `pyWebLayout/layout/README_EREADER_API.md` - EbookReader API reference (in source)
## Debug/Development Scripts
Low-level debug and rendering scripts have been moved to the `scripts/` directory.