Skip to content

A powerful Python + PyQt5 GUI application for visually designing workflows using draggable nodes and connections. Drag-and-drop visual workflow editor with execution and validation. Python desktop app powered by PyQt5.

License

Notifications You must be signed in to change notification settings

BaseMax/qt-workflow-designer

Repository files navigation

Qt Workflow Designer

A powerful Python + PyQt5 GUI application for visually designing workflows using draggable nodes and connections.

Qt Workflow Designer

Features

  • Visual Workflow Design: Drag-and-drop interface for creating workflow diagrams
  • 🔗 Smart Connections: Create connections between nodes with automatic cycle detection
  • Validation: Built-in validation to ensure workflow integrity
  • ⚙️ Node Configuration: Configure node parameters through the properties panel
  • 📊 Execution Order: Automatic topological sorting for workflow execution
  • 💾 Save/Load: Save and load workflows to/from JSON files
  • 🔍 Zoom & Pan: Zoomable canvas with mouse wheel zoom and middle-button pan
  • 🎨 Clean Qt UX: Modern, intuitive user interface with Qt5
  • 🔌 Extensible: Easy to add custom node types through the node registry

Node Types

Start Node

  • Entry point for the workflow
  • Cannot have inputs
  • Must have at least one output
  • Color: Green

Process Node

  • Performs data transformations
  • Requires at least one input and one output
  • Configurable parameters: operation, value
  • Color: Blue

Decision Node

  • Conditional branching
  • Requires one input and multiple outputs (for true/false branches)
  • Configurable parameter: condition
  • Color: Orange
  • Shape: Diamond

End Node

  • Terminal point for the workflow
  • Must have at least one input
  • Cannot have outputs
  • Color: Red

Installation

Requirements

  • Python 3.6 or higher
  • PyQt5 5.15.0 or higher

Install Dependencies

pip install -r requirements.txt

Or install PyQt5 directly:

pip install PyQt5>=5.15.0

Usage

Running the Application

python main.py

Or if you made it executable:

./main.py

Creating a Workflow

  1. Add Nodes:

    • Use the toolbar buttons to add nodes
    • Right-click on the canvas and select "Add Node"
    • Nodes appear at the center of the current view or at the clicked position
  2. Connect Nodes:

    • Select a node and drag to another node (currently requires manual connection implementation)
    • Or implement connection by selecting source and target nodes
  3. Configure Nodes:

    • Click on a node to select it
    • Edit properties in the right-side Properties panel
    • Change the node title
    • Set parameters specific to the node type
  4. Move Nodes:

    • Click and drag nodes to reposition them
    • Connections automatically update when nodes move
  5. Delete Nodes/Connections:

    • Select items and press Delete or Backspace
    • Or right-click and select "Delete Selected"

Canvas Controls

  • Zoom In: Mouse wheel up, Ctrl+Plus, or View menu
  • Zoom Out: Mouse wheel down, Ctrl+Minus, or View menu
  • Reset Zoom: Ctrl+0 or View menu
  • Pan: Middle mouse button + drag
  • Select: Left click on nodes or connections
  • Multi-select: Shift+Click or drag selection box

Workflow Operations

Validate Workflow (F5)

Checks the workflow for:

  • Required start and end nodes
  • Proper node connections
  • No cycles in the graph
  • Disconnected nodes
  • Node-specific validation rules

Execute Workflow (F6)

  1. Validates the workflow
  2. Determines execution order using topological sort
  3. Executes nodes in order
  4. Displays results in the output panel

File Operations

  • New Workflow: File → New (Ctrl+N)
  • Open Workflow: File → Open (Ctrl+O) - Load from JSON
  • Save Workflow: File → Save (Ctrl+S) - Save to current file
  • Save As: File → Save As (Ctrl+Shift+S) - Save to new file
  • Exit: File → Exit (Ctrl+Q)

Architecture

The application follows a clean separation between UI and logic:

Core Logic Layer (No UI Dependencies)

  • node.py: Base node classes and node types

    • Node: Base class for all nodes
    • StartNode, ProcessNode, DecisionNode, EndNode: Specific node types
    • NodeRegistry: Registry for extensible node system
    • NodeParameter: Parameter definition system
  • workflow_graph.py: Workflow graph management

    • WorkflowGraph: Manages nodes and connections
    • Validation logic (cycle detection, connection rules)
    • Execution order determination (topological sort)
    • JSON serialization/deserialization

UI Layer (PyQt5)

  • graphics_items.py: Visual node representations

    • GraphicsNode: Visual representation of nodes
    • GraphicsConnection: Visual representation of connections
  • workflow_canvas.py: Canvas with zoom/pan

    • WorkflowScene: Graphics scene for the workflow
    • WorkflowView: View with zoom and pan support
  • main_window.py: Main application window

    • MainWindow: Application window with menus and toolbars
    • PropertiesPanel: Node configuration panel
  • main.py: Application entry point

Extending the System

Adding Custom Node Types

  1. Define a new NodeType in node.py:
class NodeType(Enum):
    # ... existing types ...
    CUSTOM = "custom"
  1. Create a custom node class:
class CustomNode(Node):
    def __init__(self, node_id=None, x=0, y=0):
        super().__init__(node_id, NodeType.CUSTOM, "Custom", x, y)
    
    def get_parameter_definitions(self):
        return [
            NodeParameter("param1", str, "default", "Description")
        ]
    
    def validate(self):
        # Custom validation logic
        return True, ""
    
    def execute(self, input_data):
        # Custom execution logic
        return input_data
  1. Register the node type:
NodeRegistry.register_node_type(NodeType.CUSTOM, CustomNode)
  1. Add a color in graphics_items.py:
NODE_COLORS = {
    # ... existing colors ...
    NodeType.CUSTOM: QColor(150, 100, 200)
}

JSON File Format

Workflows are saved in JSON format:

{
  "nodes": [
    {
      "id": "uuid-string",
      "type": "start",
      "title": "Start",
      "x": 100.0,
      "y": 100.0,
      "parameters": {},
      "inputs": [],
      "outputs": ["uuid-of-connected-node"]
    }
  ],
  "connections": [
    ["from-node-id", "to-node-id"]
  ]
}

Development

Project Structure

qt-workflow-designer/
├── main.py                 # Application entry point
├── main_window.py          # Main window and UI
├── workflow_canvas.py      # Scene and view with zoom/pan
├── graphics_items.py       # Visual node representations
├── workflow_graph.py       # Workflow logic and execution
├── node.py                 # Node classes and types
├── requirements.txt        # Python dependencies
├── .gitignore             # Git ignore rules
├── README.md              # This file
└── LICENSE                # License file

Code Organization

  • Separation of Concerns: UI code is separate from business logic
  • Extensibility: Node system designed for easy extension
  • Validation: Multiple validation layers for data integrity
  • Clean Architecture: Each module has a single, well-defined responsibility

License

See the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Troubleshooting

PyQt5 Installation Issues

If you have trouble installing PyQt5:

On Ubuntu/Debian:

sudo apt-get install python3-pyqt5

On macOS with Homebrew:

brew install pyqt5

Using conda:

conda install pyqt

Application Won't Start

Make sure you have Python 3.6+ and PyQt5 installed:

python --version
python -c "from PyQt5 import QtWidgets; print('PyQt5 OK')"

Future Enhancements

  • Undo/Redo functionality
  • Copy/Paste nodes
  • Node grouping
  • Subworkflows
  • Export to image
  • Dark theme support
  • Interactive connection creation with visual feedback
  • Grid snap for node positioning
  • Workflow templates
  • Plugin system for custom nodes

About

A powerful Python + PyQt5 GUI application for visually designing workflows using draggable nodes and connections. Drag-and-drop visual workflow editor with execution and validation. Python desktop app powered by PyQt5.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages