This is a Python educational project focused on learning Python through AI-assisted development. It demonstrates progressive complexity from basic CLI programs to GUI applications, following a tutorial-based learning path (in Hebrew).
All rectangle calculators share the same core function:
def calculate_rectangle_properties(width, height):
area = width * height
perimeter = 2 * (width + height)
return area, perimeterKey: Always reuse this exact function signature across all rectangle implementations to maintain consistency.
The project follows a specific progression pattern:
rectangle.py- Interactive CLI with input validationrectangle_argv.py- Command-line arguments using argparserectangle_gui.py- Tkinter GUI with ttk stylingrectangle_flet.py- Modern Flet-based GUI (multi-implementation file)rectangle_flet_fixed.py- Refined Flet implementation
- Always use
uvfor package management (not pip/venv) - Python version: 3.12+ (specified in
.python-version) - Dependencies managed in
pyproject.toml - Run commands with:
uv run python <file.py>
- Uses pytest with plain functions (not unittest classes)
- Test file:
test_rectangle.py - Pattern: Test both the core function and main() with mocking
- Example test structure:
def test_calculate_rectangle_properties_positive_integers():
area, perimeter = calculate_rectangle_properties(5, 3)
assert area == 15
assert perimeter == 16- Tkinter (
rectangle_gui.py) - Basic GUI, class-based structure - Flet (
rectangle_flet*.py) - Modern web-based GUI, function-based structure
- Base functionality:
rectangle.py - Variants:
rectangle_<interface_type>.py(argv, gui, flet) - Fixed versions:
rectangle_<type>_fixed.py
- CLI: Try-catch with user-friendly error messages
- GUI: Visual feedback with status text and message boxes
- Always validate positive numbers for dimensions
- Function docstrings with Args/Returns sections
- Inline comments for GUI setup and validation logic
- Class docstrings for GUI classes:
"""GUI application for rectangle calculations."""
Every rectangle calculator must import and use the same calculate_rectangle_properties() function to ensure consistent calculations across all interfaces.
- Flet implementations use nested functions for event handlers
- Tkinter uses class methods for state management
- Both patterns include clear/reset functionality
rectangle_argv.py uses argparse with:
- Positional arguments for width/height
- Optional verbose flag (
-v, --verbose) - Built-in help and validation
- Reuse the core calculation function - never reimplement the math
- Follow the progressive complexity pattern when adding new interfaces
- Use
uv runfor all Python execution - Write pytest functions, not unittest classes
- Include comprehensive input validation in all implementations
- Maintain consistent error messaging across all interfaces
- Add type annotation to every function.
- Make sure none of the function names are defined more than once.
- Write tests for every function.
uv run pytest # Run a
ll tests
uv run python rectangle.py # Interactive CLI
uv run python rectangle_argv.py 5 3 # Command-line usage
uv run python rectangle_gui.py # Tkinter GUI
uv run python rectangle_flet.py # Modern Flet GUI