Allow label display in litegraph based on node definition in python

This commit is contained in:
MaraScott 2024-05-21 17:39:58 +02:00
parent ece5acb8e8
commit 699f54d740
4 changed files with 17 additions and 5 deletions

View File

@ -75,6 +75,7 @@ function convertToInput(node, widget, config) {
const sz = node.size;
node.addInput(widget.name, type, {
widget: { name: widget.name, [GET_CONFIG]: () => config },
label: widget.element?.placeholder ? widget.element?.placeholder : widget.name
});
for (const widget of node.widgets) {

View File

@ -3379,7 +3379,7 @@
* @param {Object} extra_info this can be used to have special properties of an output (label, special color, position, etc)
*/
LGraphNode.prototype.addOutput = function(name, type, extra_info) {
var output = { name: name, type: type, links: null };
var output = { name: name, label: extra_info.label, type: type, link: null };
if (extra_info) {
for (var i in extra_info) {
output[i] = extra_info[i];
@ -3470,7 +3470,7 @@
*/
LGraphNode.prototype.addInput = function(name, type, extra_info) {
type = type || 0;
var input = { name: name, type: type, link: null };
var input = { name: name, label: extra_info.label, type: type, link: null };
if (extra_info) {
for (var i in extra_info) {
input[i] = extra_info[i];

View File

@ -1646,6 +1646,8 @@ export class ComfyApp {
for (const inputName in inputs) {
const inputData = inputs[inputName];
const type = inputData[0];
const extra_infos = inputData[1];
const inputLabel = extra_infos?.label ? extra_infos.label : inputName
let widgetCreated = true;
const widgetType = self.getWidgetType(inputData, inputName);
@ -1657,7 +1659,7 @@ export class ComfyApp {
}
} else {
// Node connection inputs
this.addInput(inputName, type);
this.addInput(inputName, type, { label: inputLabel });
widgetCreated = false;
}
@ -1674,9 +1676,17 @@ export class ComfyApp {
for (const o in nodeData["output"]) {
let output = nodeData["output"][o];
if(output instanceof Array) output = "COMBO";
const outputName = nodeData["output_name"][o] || output;
let outputName = output;
let outputLabel = outputName;
if(nodeData["output_name"][o] instanceof Array) {
outputName = nodeData["output_name"][o][0] || output;
outputLabel = nodeData["output_name"][o][1]
} else {
outputName = nodeData["output_name"][o] || output;
outputLabel = outputName
}
const outputShape = nodeData["output_is_list"][o] ? LiteGraph.GRID_SHAPE : LiteGraph.CIRCLE_SHAPE ;
this.addOutput(outputName, output, { shape: outputShape });
this.addOutput(outputName, output, { shape: outputShape, label: outputLabel });
}
const s = this.computeSize();

View File

@ -346,6 +346,7 @@ export const ComfyWidgets = {
STRING(node, inputName, inputData, app) {
const defaultVal = inputData[1].default || "";
const multiline = !!inputData[1].multiline;
inputData[1].placeholder = inputData[1].placeholder || inputData[1].label || inputName;
let res;
if (multiline) {