No project description provided
Project description
FlashCardGenerator
FlashCardGenerator is a Python library for creating customizable flashcards in PDF format. It's designed to be easy to use while offering flexibility in flashcard design and layout.
Features
- Create double-sided flashcards with customizable content
- Support for additional information and an index on the front of the card
- Markdown-style formatting (bold, italic, underline)
- Automatic text wrapping and resizing to fit content
- Configurable card layout (size, number per row, etc.)
- PDF output for easy printing and sharing
Installation
To install FlashCardGenerator, run the following command:
pip install flashcard-generator
Quick Start
Here's a simple example to get you started:
from flashcard_generator import FlashCardGenerator
generator = FlashCardGenerator()
generator.set_filename("my_flashcards.pdf") \
.add_entry("Bonjour", "Hello", extra="Casual greeting", index="1") \
.add_entry("Merci", "Thank you", extra="**Important** phrase", index="2") \
.add_entry("Au revoir", "Goodbye", extra="*Formal* farewell", index="3") \
.generate()
This will create a PDF file named "my_flashcards.pdf" with three flashcards.
API Usage
Creating a FlashCardGenerator
generator = FlashCardGenerator()
Configuration Methods
set_filename(filename: str) -> Self
: Set the output PDF filenameset_cards_per_row(count: int) -> Self
: Set the number of cards per rowset_page_size(size: tuple) -> Self
: Set the page size (default is A4)set_margins(top: float, bottom: float, left: float, right: float) -> Self
: Set page marginsset_card_height(height: float) -> Self
: Set the height of each card
Adding Entries
generator.add_entry(original: str, translation: str, extra: str = "", index: str = "") -> Self
original
: The text on the front of the cardtranslation
: The text on the back of the cardextra
: Additional information to display on the front (optional)index
: An index or identifier for the card, displayed in the bottom right corner (optional)
Generating the PDF
generator.generate()
This method creates the PDF file with all the added flashcards.
Markdown Formatting
You can use basic Markdown formatting in your flashcard text:
**bold**
for bold text*italic*
for italic text__underline__
for underlined text
Text Wrapping and Sizing
The FlashCardGenerator automatically wraps text that's too long to fit on a single line. If the wrapped text is still too large for the card, it will progressively reduce the font size to make the content fit.
Example
Here's a more detailed example showcasing various features:
from flashcard_generator import FlashCardGenerator
from reportlab.lib.units import cm
generator = FlashCardGenerator()
generator.set_filename("language_flashcards.pdf") \
.set_cards_per_row(3) \
.set_card_height(4*cm) \
.add_entry("Bonjour", "Hello", extra="Casual greeting", index="1") \
.add_entry("Merci beaucoup", "Thank you very much", extra="**Important** phrase for expressing gratitude", index="2") \
.add_entry("Au revoir", "Goodbye", extra="*Formal* farewell", index="3") \
.add_entry("S'il vous plaît", "Please", extra="__Polite__ request", index="4") \
.add_entry("Comment allez-vous?", "How are you?", extra="Formal way to ask about someone's wellbeing", index="5") \
.add_entry("Je ne comprends pas", "I don't understand", extra="Useful phrase when you're confused", index="6") \
.generate()
This will create a PDF with 3 cards per row, each card 4 cm high, and include 6 flashcards with various formatting styles, extra information, and indices.
Contributing
Contributions to FlashCardGenerator are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flashcard_generator-0.1.1.tar.gz
.
File metadata
- Download URL: flashcard_generator-0.1.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.19 Linux/6.1.0-25-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ebcf966e9c37e094e22d683139153b28eb248167ebde4ecb47e3e4ff6e7a292 |
|
MD5 | 8b0f288ed98280b9fcdd1c8d8ccfa5c8 |
|
BLAKE2b-256 | 8714e6b97cdcb532cb968d319129a427ad0e4ece1253fb471a93c90a7d8fe987 |
File details
Details for the file flashcard_generator-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: flashcard_generator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.19 Linux/6.1.0-25-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96ae675fa8c1bb634e4639bd4ef34f7d6728ca74789a98cf3223e39404e110b4 |
|
MD5 | 4b2d8f5b4f1c0d138a6586a9a649c4c2 |
|
BLAKE2b-256 | f64f667e3d28189a68deb8a51741f8636c8bd08e5008473d77c069da458f80b1 |