mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-21 20:52:11 -03:00
0.31
This commit is contained in:
33
show_text.py
33
show_text.py
@@ -1,18 +1,43 @@
|
||||
class Everything(str):
|
||||
def __ne__(self, _):
|
||||
return False
|
||||
|
||||
class ShowText:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"text_value": ("STRING", {"forceInput": True}),
|
||||
"text_int_float": (Everything("*"), {"forceInput": True}),
|
||||
},
|
||||
}
|
||||
|
||||
INPUT_IS_LIST = True
|
||||
RETURN_TYPES = ()
|
||||
FUNCTION = "show_text"
|
||||
OUTPUT_NODE = True
|
||||
INPUT_IS_LIST = (True,)
|
||||
CATEGORY = "Bjornulf"
|
||||
|
||||
def show_text(self, text_value):
|
||||
return {"ui": {"text": text_value}}
|
||||
def detect_type(self, value):
|
||||
if isinstance(value, int):
|
||||
return 'integer'
|
||||
elif isinstance(value, float):
|
||||
# Check if it has a decimal part
|
||||
if value % 1 == 0:
|
||||
return 'float' if str(value).endswith('.0') else 'integer'
|
||||
return 'float'
|
||||
elif isinstance(value, str):
|
||||
try:
|
||||
float_val = float(value)
|
||||
if '.' in value:
|
||||
return 'float string'
|
||||
if float_val.is_integer():
|
||||
return 'integer string'
|
||||
return 'float string'
|
||||
except ValueError:
|
||||
return 'normal string'
|
||||
else:
|
||||
return 'other type'
|
||||
|
||||
def show_text(self, text_int_float):
|
||||
type_info = [f"{value}" for value in text_int_float]
|
||||
return {"ui": {"text": type_info}}
|
||||
Reference in New Issue
Block a user