Add .gitignore for Python cache files and remove unused GetRandomDimensions class

This commit is contained in:
var1ableX
2025-09-17 22:41:53 -04:00
parent f738b309f2
commit d2ce756a88
3 changed files with 26 additions and 68 deletions
+2
View File
@@ -0,0 +1,2 @@
__pycache__/__init__.cpython-312.pyc
__pycache__/nodes.cpython-312.pyc
-45
View File
@@ -108,51 +108,6 @@ class isImageEmpty:
return (is_empty,) # Return a tuple as required by ComfyUI
import random
class GetRandomDimensions:
def __init__(self):
self.is_changed_enabled = True
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"min_width": ("INT", {"default": 768, "step": 16, "display": "number"}),
"min_height": ("INT", {"default": 768, "step": 16, "display": "number"}),
"max_width": ("INT", {"default": 1280, "step": 16, "display": "number"}),
"max_height": ("INT", {"default": 1280, "step": 16, "display": "number"}),
"randomize": ("BOOLEAN", {"default": False}),
}
}
RETURN_TYPES = ("INT", "INT")
RETURN_NAMES = ("width", "height",)
FUNCTION = "execute"
CATEGORY = "image"
OUTPUT_NODE = True
def execute(self, min_width, min_height, max_width, max_height, randomize ):
def get_random_dimensions(min_val, max_val):
min_div_16 = min_val // 16
max_div_16 = max_val // 16
if min_div_16 > max_div_16:
raise ValueError("No numbers in the specified range are divisible by 16.")
return random.randint(min_div_16, max_div_16) * 16
if randomize:
width = get_random_dimensions(min_width, max_width)
height = get_random_dimensions(min_height, max_height)
else:
width, height = max_width, max_height
# Setting the resolution string
text = f"{width}x{height}"
#return width, height
return {"ui": {"text": text},
"result": (width, height, text)}
# wildcard trick is taken from pythongossss's
class AnyType(str):
def __ne__(self, __value: object) -> bool:
+24 -23
View File
@@ -53,30 +53,31 @@ function addNewColors() {
// Function to enhance nodes with text display
function addTextDisplay(nodeType) {
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
const r = onNodeCreated?.apply(this, arguments);
const w = ComfyWidgets["STRING"](this, "display", ["STRING", { multiline: true, placeholder: " " }], app).widget;
w.inputEl.readOnly = true;
w.inputEl.style.opacity = 0.7;
w.inputEl.style.cursor = "auto";
return r;
};
//IMPORTANT: This function is disabled because it is somehow breaking Note nodes. Needs further investigation.
// function addTextDisplay(nodeType) {
// const onNodeCreated = nodeType.prototype.onNodeCreated;
// nodeType.prototype.onNodeCreated = function () {
// const r = onNodeCreated?.apply(this, arguments);
// const w = ComfyWidgets["STRING"](this, "display", ["STRING", { multiline: true, placeholder: " " }], app).widget;
// w.inputEl.readOnly = true;
// w.inputEl.style.opacity = 0.7;
// w.inputEl.style.cursor = "auto";
// return r;
// };
const onExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, arguments);
// const onExecuted = nodeType.prototype.onExecuted;
// nodeType.prototype.onExecuted = function (message) {
// onExecuted?.apply(this, arguments);
for (const widget of this.widgets) {
if (widget.type === "customtext" && widget.name === "display" && widget.inputEl.readOnly === true) {
widget.value = message.text.join('');
}
}
// for (const widget of this.widgets) {
// if (widget.type === "customtext" && widget.name === "display" && widget.inputEl.readOnly === true) {
// widget.value = message.text.join('');
// }
// }
this.onResize?.(this.size);
};
}
// this.onResize?.(this.size);
// };
// }
app.registerExtension({
name: "rka.GetRandomDimensions",
@@ -97,10 +98,10 @@ app.registerExtension({
});
// Call the function to add new colors
//addNewColors();
},
}/*,
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (["GetRandomDimensions"].includes(nodeData.name)) {
addTextDisplay(nodeType);
}
},
},*/
});