I want to create the Label using ghPython code instead of directly using component from HumanUI tab.
Context: I want to have my labels created based on number of input in each case. It can have 3 labels or 10 labels based on code argument.
Problem: When I tried using code as written below I am not able to create the label. The label contains none if I run this script.
import rhinoscriptsyntax as rs
import ghpythonlib as ghp
l1 = ghp.components.HumanUI.CreateLabel(“Testing”,12,1)
w1 = ghp.components.HumanUI.LaunchWindow(True, “Test”, 300,300)
a1 = ghp.components.HumanUI.AddElements(w1,l1)
l1 doesnt contain anything if we run above code.
I am sure I am doing something wrong so can please someone help me identifying the problem here?
June 30, 2022, 11:04am
I would be very surprised if it were possible to create Human UI elements from Python. I do not recommend this strategy.
Also, it is not possible to dynamically change the number of elements in a Human UI window. Your only option is to create more elements than you might need and programmatically hide/show them:
HumanUI: ...but I DO need to drive the creation of elements with the results of a value listener...? - #2 by andheum
Thanks Andrew. I think its definitely possible to create the HumanUI element from python because the code output of what I mentioned in the question is a HumanUI window. I am able to show the HumanUI window with using HumanUI component inside ghPythonlib.
However, the strategy you mentioned in the answer is certainly very good workaround which I did not think of earlier. I will try it.
Thank you again.