chrisgoringe / Comfy-Custom-Node-How-To

An unofficial practical guide to getting started developing custom nodes for ComfyUI
GNU General Public License v3.0
143 stars 5 forks source link

Propose documentation addition for INPUT_TYPES #23

Closed corbin-hayden13 closed 1 day ago

corbin-hayden13 commented 2 days ago

I propose an addition to custom widgets documentation regarding passing serialized custom widget data from javascript to python. Credit goes to rgthree for finding an awesome solution:

This ContainsAnyDict class creates an easy way to receive serialized data from custom widgets from javascript as kwargs to the FUNCTION in python whereas even if the custom widgets were serialized they would not be passed to the function in any capacity.

class ContainsAnyDict(dict):
    def __contains__(self, key):
        return True
...

@classmethod
def INPUT_TYPES(s):
    return {
        "required": {},
        "optional": ContainsAnyDict()
    }
chrisgoringe commented 1 day ago

Thanks. I'm not making changes here any more, instead I'm working on the documentation at docs.comfy.org. I'll be adding this over there!