Clearing the list of a ComboBox (Dropdown) - Python API
-
I want to use dropdown to select an object from a list of children from the targeted object. I managed to populate it just fine, but the issue is, how do you clear it so that I can repopulate the list when a different object is targeted later?
# Initialize dropdown for each parameter for i, param in enumerate(self.params): self.AddComboBox(ID_DROPDOWN + i) # Once a target is selected for i in range(len(self.params)): for j, child in enumerate(self.children): self.AddChild(ID_DROPDOWN + i, j+1, child)
My current idea is to remove the dropdown element entirely, but then I would have a hard time putting the dropdowns back in their respective layout positions like before.
-
Hey @ezeuz,
thank you for reaching out to us. Dynamic UIs are possible with
GeDialog
but there is no data model abstraction as you might be accustomed to by newer UIs. So, you have to rebuild your UI by hand. I once showed here how to do something like that while also implementing a very simple data model.But for freeing the children of popup buttons and combo boxes, you do not need all that, there you can just call GeDialog.FreeChildren. But just like for the larger level of fully dynamic dialog UIs, it is probably best to write yourself a small abstraction with a property
MyComboItems
or something like that. Look at my code example I linked to when you are lost on what I mean with that, there I implemented a propertyItems
which in this case populated a list of items, but you could write something similar for your combo box content (and state).Cheers,
Ferdinand -
@ferdinand Thanks a ton again! Yeah that dynamic UI is indeed something that fits perfectly with my current case, and possibly some other features I want to implement. Tho, I will revisit it later once I get to creating an MVP for my plugin. So I will use
FreeChildren()
for now.