Dynamic Nodes? Drop down output selectors, populated dynamically #122
|
Hi. I am new to Nodezator and I have a question which is a twist on the csv loader question from 2022. I have a node which loads a file to a pandas dataframe, easy. I then would like a column_selector node with say 10 outputs (col1, col2 etc.). The name of the outputs are fixed (easy again). Now the hard bit, I want each output to have a dropdown menu listing all the columns in the dataframe. So output1 (named col1 ) can output say column "A"s data as a pd.series. The dropdown list content either needs to be dynamically populated when the file is loaded or generated when an update button on the node is used. Can this be done? If so how, as I cannot find any examples. I cannot use text input boxes to select columns, as the user may not know the column names prior to loading the data. Also the column names could be anything, so cannot be pre defined. Thank you for any help you can give. I am impressed by Nodezator and its capability. |
Replies: 1 comment 2 replies
|
Hello, theBoredGeordie, I'm afraid what you want isn't possible in Nodezator. I wouldn't mind implementing such dynamic features in Nodezator, as long as it doesn't get in the way of Nodezator's goal of being, as close as possible, a 1:1 visual representation of Python. For instance, in Python, functions always only return a single value/object. Nodes in nodezator can have multiple outputs but it is just a visual representation of what is actually a single object: a dictionary with each key representing an output. However, it seems to me that, in your case, having such dynamic sockets wouldn't save your users any time. That is, they'd still have to execute the graph once so that this theoretical node with dynamic outputs would display the sockets representing the columns. Only then your users would be able to do anything meaningful with the displayed sockets and would likely have to execute the graph again once those output sockets were connected to other meaningful nodes. Even if instead of dynamic sockets, you had a fixed number of sockets and you could also preselect the contents of the socket using a dropdown menu, like you suggested, the users would still need to execute the graph so the dropdown menu would be populated dynamically anyway. Because of that, my suggestion is to simply create a node that, upon receiving the data frame, displays the names of the available columns (using There's an example I hope this helps. Let me know if you need anything else. I might not be always so quick to reply, but I try to do my best. |
Hello, theBoredGeordie,
I'm afraid what you want isn't possible in Nodezator.
I wouldn't mind implementing such dynamic features in Nodezator, as long as it doesn't get in the way of Nodezator's goal of being, as close as possible, a 1:1 visual representation of Python. For instance, in Python, functions always only return a single value/object. Nodes in nodezator can have multiple outputs but it is just a visual representation of what is actually a single object: a dictionary with each key representing an output.
However, it seems to me that, in your case, having such dynamic sockets wouldn't save your users any time. That is, they'd still have to execute the graph once so that this theo…