Skip to main content

Dynamic widget visibility for ComfyUI nodes via simple metadata

Project description

comfy-dynamic-widgets

A Python library that enables conditional widget visibility in ComfyUI nodes via simple metadata.

Installation

pip install comfy-dynamic-widgets

Usage

For Node Authors

Add visible_when metadata to widget definitions:

@classmethod
def INPUT_TYPES(cls):
    return {
        "required": {
            "backend": (["option_a", "option_b", "option_c"], {"default": "option_a"}),
        },
        "optional": {
            "param_for_a": ("FLOAT", {
                "default": 0.1,
                "visible_when": {"backend": ["option_a"]},
            }),
            "param_for_b_and_c": ("INT", {
                "default": 10,
                "visible_when": {"backend": ["option_b", "option_c"]},
            }),
        }
    }

For Custom Node Package Authors

In your prestartup_script.py:

import json
import os

def generate_widget_mappings():
    try:
        from comfy_dynamic_widgets import scan_all_nodes, generate_mappings

        configs = scan_all_nodes()
        if not configs:
            return

        mappings = generate_mappings(configs)

        output_path = os.path.join(
            os.path.dirname(__file__), "web", "js", "mappings.json"
        )
        with open(output_path, "w") as f:
            json.dump(mappings, f, indent=2)

    except ImportError:
        print("comfy-dynamic-widgets not installed")

generate_widget_mappings()

Copy the dynamic_widgets.js from this package to your web/js/ folder and update the mappings path.

API

scan_all_nodes() -> dict

Scans all registered ComfyUI nodes and extracts visible_when metadata.

generate_mappings(configs: dict) -> dict

Transforms node visibility configs into a JS-friendly JSON format.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

comfy_dynamic_widgets-0.0.4.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comfy_dynamic_widgets-0.0.4-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file comfy_dynamic_widgets-0.0.4.tar.gz.

File metadata

  • Download URL: comfy_dynamic_widgets-0.0.4.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_dynamic_widgets-0.0.4.tar.gz
Algorithm Hash digest
SHA256 de357df120b0bfb2c6c10b20f5f3ffef737fd24bb4123a86ef6004c1b7ab21a7
MD5 686ab97071b59fa1beb6acd1dafab971
BLAKE2b-256 67d1f1fe2c2d7dc263b96b0ef421067f191385a0e21f2c06a3e2026358c5d7a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_dynamic_widgets-0.0.4.tar.gz:

Publisher: publish.yml on PozzettiAndrea/comfy-dynamic-widgets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_dynamic_widgets-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for comfy_dynamic_widgets-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e24d3c7ae41c98af01a352e3e25e8f315355a90770d040bd516a1c5649994634
MD5 ba3e14d73db885cb14908f072f2e7e20
BLAKE2b-256 a62cce9a6e6b1ff73f6959614cdc41d1cc65b89206e11cdaf3e857568cd6d16d

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_dynamic_widgets-0.0.4-py3-none-any.whl:

Publisher: publish.yml on PozzettiAndrea/comfy-dynamic-widgets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page