Merge pull request #2382 from alicevision/dev/pushButtonAttribute

[core/ui] Add support for PushButton attribute
This commit is contained in:
Fabien Castan 2024-05-17 20:11:40 +02:00 committed by GitHub
commit d9b4b26a69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 71 additions and 3 deletions

View file

@ -892,6 +892,19 @@ class BaseNode(BaseObject):
if callable(m):
m(self)
def onAttributeClicked(self, attr):
""" When an attribute is clicked, a specific function can be defined in the descriptor and be called.
Args:
attr (Attribute): attribute that has been clicked
"""
paramName = attr.name[:1].upper() + attr.name[1:]
methodName = f'on{paramName}Clicked'
if hasattr(self.nodeDesc, methodName):
m = getattr(self.nodeDesc, methodName)
if callable(m):
m(self)
def updateInternals(self, cacheDir=None):
""" Update Node's internal parameters and output attributes.
@ -1685,7 +1698,7 @@ def nodeFactory(nodeDict, name=None, template=False, uidConflict=False):
# do not perform that check for internal attributes because there is no point in
# raising compatibility issues if their number differs: in that case, it is only useful
# if some internal attributes do not exist or are invalid
if not template and (sorted([attr.name for attr in nodeDesc.inputs]) != sorted(inputs.keys()) or \
if not template and (sorted([attr.name for attr in nodeDesc.inputs if not isinstance(attr, desc.PushButtonParam)]) != sorted(inputs.keys()) or \
sorted([attr.name for attr in nodeDesc.outputs]) != sorted(outputs.keys())):
compatibilityIssue = CompatibilityIssue.DescriptionConflict