Pseudocode-driven 2D algorithm visualizer
Project description
GraphicsAlgoVisualizer
A pseudocode-driven 2D algorithm visualizer built with Python and CustomTkinter. Write algorithms in a simple DSL, pick a canvas type, and watch them execute step-by-step with animated visuals, speed control, and presentation mode.
✨ Features
- Pseudocode DSL — Write algorithms in a clean, Python-like subset with
for,while,if/elif/else, variables, expressions, and built-in functions. No Python knowledge required. - Multiple Canvas Types — Grid, Array, and Graph canvases with dedicated renderers and built-in operations.
- Bundled Algorithm Presets — Bresenham line drawing, Bubble sort, BFS pathfinding, and Dijkstra's shortest path ship out of the box as TOML presets.
- In-App Graph Editor — Click to add nodes, drag between nodes to create edges, set weights — build custom networks visually.
- Step-by-Step Playback — Play, pause, step forward, adjust speed, and see line-by-line highlighting of the executing pseudocode.
- Presentation Mode — A distraction-free, canvas-only view for demos and classroom walkthroughs.
- Theme System — Centralized theme tokens drive all canvas and UI colors for a consistent look.
- Plugin Architecture — Drop-in and entry-point based plugin loading. Extend the visualizer with custom canvas types (see the bundled
pyalgoviz-heap-canvasexample). - User Presets — Save your own algorithms as
.tomlpreset files and load them from a user presets directory.
📋 Prerequisites
- Python 3.11+
- Tkinter (usually ships with Python; see platform notes below)
- Git (to clone the repo)
🚀 Getting Started
1. Clone the Repository
git clone https://github.com/F3rNaNDEZ57/GraphicsAlgoVisualizer.git
cd GraphicsAlgoVisualizer
2. Create a Virtual Environment
macOS / Linux
python3 -m venv .venv
source .venv/bin/activate
Windows (PowerShell)
python -m venv .venv
.\.venv\Scripts\Activate.ps1
Windows (Command Prompt)
python -m venv .venv
.venv\Scripts\activate.bat
3. Install the Package
Install in editable (development) mode so changes take effect immediately:
pip install -e ".[dev]"
Note: The
[dev]extra includespytestfor running tests.
4. Run the Visualizer
pyalgoviz
Or run directly as a module:
python -m pyalgoviz.app
🖥️ Platform-Specific Notes
macOS
Tkinter is included with the official Python installer from python.org. If you installed Python via Homebrew, you may need to install it separately:
brew install python-tk@3.11
Linux (Debian / Ubuntu)
sudo apt update
sudo apt install python3-tk
Linux (Fedora)
sudo dnf install python3-tkinter
Linux (Arch)
sudo pacman -S tk
Windows
Tkinter is bundled with the standard Python installer from python.org. No extra steps needed — just make sure to check "tcl/tk and IDLE" during installation if using the custom installer.
🏗️ Project Structure
GraphicsAlgoVisualizer/
├── src/pyalgoviz/
│ ├── app.py # Entry point
│ ├── theme.py # Centralized theme tokens
│ ├── canvas_types.py # Side-effect import to register canvas types
│ ├── plugins.py # Plugin discovery and loading
│ ├── preset_loader.py # TOML preset loader
│ ├── canvas/ # Canvas types, renderers, and registry
│ │ ├── base.py # Abstract base canvas
│ │ ├── registry.py # Canvas type registry
│ │ ├── grid_canvas.py # Grid canvas (e.g., Bresenham)
│ │ ├── array_canvas.py # Array canvas (e.g., Bubble sort)
│ │ ├── graph_canvas.py # Graph canvas (e.g., BFS, Dijkstra)
│ │ └── tk_*_renderer.py # Tkinter renderers for each canvas
│ ├── engine/ # Step engine and playback state
│ │ ├── runner.py # Runs pseudocode on a canvas
│ │ └── playback.py # Play/pause/step state machine
│ ├── pseudocode/ # DSL interpreter
│ │ ├── interpreter.py # Pseudocode interpreter
│ │ ├── builtins_registry.py# Built-in functions (SetCell, Enqueue, etc.)
│ │ ├── step_event.py # Step event payloads
│ │ └── errors.py # Error types
│ ├── presets/ # Bundled TOML algorithm presets
│ │ ├── bresenham-line.toml
│ │ ├── bubble-sort.toml
│ │ ├── bfs-pathfinding.toml
│ │ └── dijkstra-shortest-path.toml
│ └── ui/ # CustomTkinter UI layer
│ ├── main_window.py # Main application window
│ ├── graph_editor_model.py # Headless graph editor model
│ └── graph_editor_view.py # Visual graph editor widget
├── plugins/ # Drop-in plugin directory
│ └── pyalgoviz-heap-canvas/ # Example plugin
├── tests/ # Test suite (pytest)
├── pyproject.toml # Project metadata and build config
└── .gitignore
🧪 Running Tests
pytest
Run with verbose output:
pytest -v
Run a specific test file:
pytest tests/test_interpreter.py
📝 Writing a Custom Preset
Presets are .toml files that define an algorithm's pseudocode, canvas type, and parameters. Place them in the bundled src/pyalgoviz/presets/ directory or the user presets directory.
Example — a simple grid algorithm:
[meta]
name = "My Algorithm"
canvas = "grid"
[params]
width = 20
height = 20
[source]
code = """
for x in Range(0, 10):
SetCell(x, x, "visited")
"""
Supported Canvas Types
| Canvas | Use Case | Key Builtins |
|---|---|---|
grid |
2D grid algorithms | SetCell, GetCell, Mark |
array |
Sorting / linear data | Swap, Compare, SetIndex |
graph |
Graph traversal / shortest path | Enqueue, Dequeue, MarkEdge |
🔌 Plugins
The visualizer supports two plugin mechanisms:
- Drop-in plugins — Place a Python package in the
plugins/directory. It will be auto-discovered on startup. - Entry-point plugins — Register a
pyalgoviz.canvasesentry point in your package'spyproject.toml. Installed packages with this entry point are loaded automatically.
See plugins/pyalgoviz-heap-canvas/ for a working example.
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes
- Run the tests (
pytest) - Commit with a descriptive message (
git commit -m "Add my feature") - Push to your fork (
git push origin feature/my-feature) - Open a Pull Request
📄 License
MIT — see LICENSE 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyalgoviz-0.1.0.tar.gz.
File metadata
- Download URL: pyalgoviz-0.1.0.tar.gz
- Upload date:
- Size: 50.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05aebde81439eafa907ede2560351f0f369f8bcc82417964e614ff28dafbffca
|
|
| MD5 |
529fb919e39c70be62f32992bd1b269e
|
|
| BLAKE2b-256 |
82234eec1781e46a0977fce440017189b4caee23b624c1964cc41386fa986d47
|
Provenance
The following attestation bundles were made for pyalgoviz-0.1.0.tar.gz:
Publisher:
publish-pyalgoviz.yml on F3rNaNDEZ57/GraphicsAlgoVisualizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyalgoviz-0.1.0.tar.gz -
Subject digest:
05aebde81439eafa907ede2560351f0f369f8bcc82417964e614ff28dafbffca - Sigstore transparency entry: 2149627644
- Sigstore integration time:
-
Permalink:
F3rNaNDEZ57/GraphicsAlgoVisualizer@a76f181194c9ef21d65569ce6d5e6d07857004a6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/F3rNaNDEZ57
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pyalgoviz.yml@a76f181194c9ef21d65569ce6d5e6d07857004a6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyalgoviz-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyalgoviz-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81cb780b433bfa7e6196111c1924a45710c3c39b79094a47642bffa1f15a0f62
|
|
| MD5 |
590b55dd90d13e45c0f6559b401f9add
|
|
| BLAKE2b-256 |
a4cac119e23163000b58a6621393ab25d4ac01d29253f82039ec329b96efca43
|
Provenance
The following attestation bundles were made for pyalgoviz-0.1.0-py3-none-any.whl:
Publisher:
publish-pyalgoviz.yml on F3rNaNDEZ57/GraphicsAlgoVisualizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyalgoviz-0.1.0-py3-none-any.whl -
Subject digest:
81cb780b433bfa7e6196111c1924a45710c3c39b79094a47642bffa1f15a0f62 - Sigstore transparency entry: 2149627696
- Sigstore integration time:
-
Permalink:
F3rNaNDEZ57/GraphicsAlgoVisualizer@a76f181194c9ef21d65569ce6d5e6d07857004a6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/F3rNaNDEZ57
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pyalgoviz.yml@a76f181194c9ef21d65569ce6d5e6d07857004a6 -
Trigger Event:
push
-
Statement type: