A comprehensive PyQt5-based desktop application for designing, visualizing, and simulating decision trees. This tool provides an intuitive graphical interface for creating complex decision logic flows with visual execution tracing.
- π¨ Visual Node Editor: Drag-and-drop interface for creating decision trees
- π Multiple Node Types: Start, Decision, Action, and End nodes
- βοΈ Condition Builder: Create complex conditions with various operators
- π― Execution Tracing: Step-by-step visualization of decision tree execution
- π Statistics Panel: Real-time tree metrics and analysis
- πΎ Import/Export: Save and load trees in JSON format
- π Zoom & Pan: Navigate large trees with ease
- Start Node: Entry point of the decision tree (green, rounded)
- Decision Node: Conditional branching based on variables (blue, diamond)
- Action Node: Execute actions or operations (yellow, rectangle)
- End Node: Terminal node in the tree (red, rounded)
==Equal to!=Not equal to>Greater than<Less than>=Greater than or equal to<=Less than or equal tocontainsString containment check
- Python 3.6 or higher
- pip package manager
pip install -r requirements.txtOr install PyQt5 directly:
pip install PyQt5>=5.15.0python main.pyOr make it executable (Linux/Mac):
chmod +x main.py
./main.py-
Add Nodes:
- Right-click on canvas β "Add Node" β Select node type
- Or use toolbar buttons to add nodes at center
- Or use Edit menu β "Add Node"
-
Edit Nodes:
- Right-click on a node β "Edit Node"
- Configure label, conditions (for decision nodes), or actions (for action nodes)
-
Connect Nodes:
- Right-click on a node β "Connect To" β Select target node
- For decision nodes: Choose "Connect True Branch" or "Connect False Branch"
-
Move Nodes:
- Click and drag nodes to reposition them
- Use mouse wheel to zoom in/out
- Click and drag on empty space to pan
- Click "Execute" in toolbar or press F5
- Enter variable values in the execution dialog:
age = 25 score = 85.5 name = John - Click OK to execute
- View execution path highlighted in red on the canvas
- Check execution trace in the bottom panel
- New Tree: File β New (Ctrl+N)
- Open Tree: File β Open (Ctrl+O)
- Save Tree: File β Save (Ctrl+S)
- Save As: File β Save As (Ctrl+Shift+S)
- Export JSON: File β Export JSON
- Import JSON: File β Import JSON
Trees are saved in JSON format with the following structure:
{
"name": "My Decision Tree",
"root_id": "node_id",
"nodes": {
"node_id": {
"id": "node_id",
"type": "decision",
"label": "Check Age",
"position": [100, 200],
"condition": {
"variable": "age",
"operator": ">=",
"value": "18"
},
"true_child": "true_node_id",
"false_child": "false_node_id"
}
}
}Ctrl+N- New treeCtrl+O- Open treeCtrl+S- Save treeCtrl+Shift+S- Save tree asF5- Execute treeCtrl++- Zoom inCtrl+-- Zoom outCtrl+0- Reset zoomCtrl+Q- Quit application
Start β Check Age β (age >= 18) β True: Grant Access / False: Deny Access β End
Start β Check Score β (score >= 90) β True: Grade A
β False: Check Score β (score >= 80) β True: Grade B
β False: Check Score β (score >= 70) β True: Grade C
β False: Grade F
Start β Check Budget β (budget > 1000) β True: Premium Products
β False: Check Category β (category == "electronics") β ...
qt-decision-tree-studio/
βββ main.py # Application entry point
βββ main_window.py # Main window with menus and panels
βββ models.py # Data models (TreeNode, DecisionTree, Condition)
βββ graphics.py # Graphical node and edge widgets
βββ canvas.py # Canvas scene and view for tree visualization
βββ dialogs.py # Dialog windows (node editor, execution)
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ LICENSE # MIT License
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Max Base
- Built with PyQt5
- Inspired by visual programming tools and decision tree algorithms