Skip to content

Commit

Permalink
Add documentation on check_lazy_status
Browse files Browse the repository at this point in the history
  • Loading branch information
guill committed Jun 17, 2024
1 parent 9d62456 commit 4712df8
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions custom_nodes/example_node.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,23 @@ class Example:
"min": 0, #Minimum value
"max": 4096, #Maximum value
"step": 64, #Slider's step
"display": "number" # Cosmetic only: display as "number" or "slider"
"display": "number", # Cosmetic only: display as "number" or "slider"
"lazy": True # Will only be evaluated if check_lazy_status requires it
}),
"float_field": ("FLOAT", {
"default": 1.0,
"min": 0.0,
"max": 10.0,
"step": 0.01,
"round": 0.001, #The value represeting the precision to round to, will be set to the step value by default. Can be set to False to disable rounding.
"display": "number"}),
"display": "number",
"lazy": True
}),
"print_to_screen": (["enable", "disable"],),
"string_field": ("STRING", {
"multiline": False, #True if you want the field to look like the one on the ClipTextEncode node
"default": "Hello World!"
"default": "Hello World!",
"lazy": True
}),
},
}
Expand All @@ -80,6 +84,23 @@ class Example:

CATEGORY = "Example"

def check_lazy_status(self, image, string_field, int_field, float_field, print_to_screen):
"""
Return a list of input names that need to be evaluated.

This function will be called if there are any lazy inputs which have not yet been
evaluated. As long as you return at least one field which has not yet been evaluated
(and more exist), this function will be called again once the value of the requested
field is available.

Any evaluated inputs will be passed as arguments to this function. Any unevaluated
inputs will have the value None.
"""
if print_to_screen == "enable":
return ["int_field", "float_field", "string_field"]
else:
return []

def test(self, image, string_field, int_field, float_field, print_to_screen):
if print_to_screen == "enable":
print(f"""Your input contains:
Expand Down

0 comments on commit 4712df8

Please sign in to comment.