How kgshear/crogen works
Purpose and Entry Point
Crogen is a desktop crochet-pattern authoring tool. Users build rows of stitch types in a Tkinter UI, see a corresponding Blender-based 3D crochet model, and generate written instructions. The application starts from src/main.py.
Application Structure
The code follows an MVC-like split:
• Controllers coordinate user actions and transitions: src/controllers/Controller.py, src/controllers/CreationController.py, src/controllers/DetailController.py, src/controllers/PatternController.py.
• Domain/model logic represents the crochet design and stitches: src/models/CrochetModel.py, src/models/CrochetStitch.py.
• Tkinter-facing views and generated UI screens live under src/ui/, including src/ui/View.py and src/ui/Crogen.py.
Creation Workflow
Pattern construction is centered on the creation screen. The creation controller accepts operations such as adding a quantity/type of stitch, creating rows, clearing, and undoing/redoing edits, then updates the model and view. Relevant boundaries are src/controllers/CreationController.py, src/models/CrochetModel.py, and src/ui/Creation/build/CreationView.py.
Crochet Domain State
CrochetModel is the likely authoritative in-memory representation of the pattern: ordered rows plus their stitch contents and edit history. CrochetStitch encapsulates stitch identity/behavior used by both written-pattern generation and model assembly. Core paths: src/models/CrochetModel.py and src/models/CrochetStitch.py.
3D Model Integration
Blender is a material runtime dependency and supplies reusable stitch geometry. Stitch-specific .blend assets provide the visual primitives used to assemble/update the 3D representation, including src/models/assets/single-crochet.blend, src/models/assets/double-crochet.blend, and src/models/assets/chain-stitch.blend. The model layer forms the boundary between abstract crochet rows/stitches and Blender scene/assets.
Pattern Output and Detail Views
The pattern controller converts current crochet state into a human-readable written pattern, while the detail controller/view supports inspection or presentation of generated results. Main components are src/controllers/PatternController.py, src/controllers/DetailController.py, src/ui/Pattern/build/PatternView.py, and src/ui/Detail/build/DetailView.py.
UI Runtime and Navigation
Tkinter is the desktop UI runtime. src/ui/Crogen.py and src/ui/View.py likely establish the root application/window and common view behavior; generated screen modules render individual stages. Controllers mediate UI callbacks rather than exposing model operations directly to views. No server, database, or remote external service is indicated.
Main entry points: CrochetModel.py Crochet model · View.py Base view · Controller.py Navigation controller · PatternController.py Pattern controller
Components 16
Tkinter UI
Desktop shell and workflow screens.
- App shell · Establishes the desktop application window.
src/ui/Crogen.py - Base view · Provides common view behavior.
src/ui/View.py - Creation screen · Captures row and stitch editing actions.
src/ui/Creation/build/CreationView.py - Pattern screen · Renders written pattern output.
src/ui/Pattern/build/PatternView.py - Detail screen · Presents generated pattern details.
src/ui/Detail/build/DetailView.py
Controllers
Coordinate UI actions and workflow transitions.
- Navigation controller · Coordinates application-level transitions.
src/controllers/Controller.py - Creation controller · Applies add, row, clear, undo, and redo operations.
src/controllers/CreationController.py - Pattern controller · Converts crochet state into written instructions.
src/controllers/PatternController.py - Detail controller · Coordinates detail presentation.
src/controllers/DetailController.py
Crochet Domain
Authoritative pattern state and stitch semantics.
- Crochet model · Owns ordered rows, stitches, and edit history.
src/models/CrochetModel.py - Crochet stitch · Defines stitch identity and behavior.
src/models/CrochetStitch.py
3D Integration
Blender-backed stitch geometry and scene assembly.
- Blender assembly · Maps crochet rows and stitches into the 3D representation.
src/models/CrochetModel.py - Single crochet asset
src/models/assets/single-crochet.blend - Double crochet asset
src/models/assets/double-crochet.blend - Chain stitch asset
src/models/assets/chain-stitch.blend
Other components
- Application entry
src/main.py
Connections 21
- Application entry → App shell: starts
- App shell → Base view: uses
- App shell → Navigation controller: initializes
- Base view → Creation screen: shared behavior
- Base view → Pattern screen: shared behavior
- Base view → Detail screen: shared behavior
- Navigation controller → Creation controller: routes to
- Navigation controller → Pattern controller: routes to
- Navigation controller → Detail controller: routes to
- Creation screen → Creation controller: edit callbacks
- Creation controller → Crochet model: edits state
- Crochet model → Crochet stitch: contains
- Crochet model → Blender assembly: assembles 3D model
- Blender assembly → Single crochet asset: loads
- Blender assembly → Double crochet asset: loads
- Blender assembly → Chain stitch asset: loads
- Pattern controller → Crochet model: reads state
- Pattern controller → Crochet stitch: formats stitches
- Pattern controller → Pattern screen: updates output
- Detail controller → Crochet model: reads state
- Detail controller → Detail screen: updates