mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-23 14:06:28 +02:00
[core] PushButton attribute implemented
Add PushButtonParam class and implement onAttributeClicked method
This commit is contained in:
parent
6791f02f2d
commit
eb1a0faf97
3 changed files with 31 additions and 0 deletions
|
@ -31,6 +31,8 @@ def attributeFactory(description, value, isOutput, node, root=None, parent=None)
|
|||
cls = ListAttribute
|
||||
elif isinstance(description, desc.ChoiceParam):
|
||||
cls = ChoiceParam
|
||||
elif isinstance(description, desc.PushButtonParam):
|
||||
cls = PushButtonParam
|
||||
else:
|
||||
cls = Attribute
|
||||
attr = cls(node, description, isOutput, root, parent)
|
||||
|
@ -398,6 +400,13 @@ def raiseIfLink(func):
|
|||
return func(attr, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
class PushButtonParam(Attribute):
|
||||
def __init__(self, node, attributeDesc, isOutput, root=None, parent=None):
|
||||
super(PushButtonParam, self).__init__(node, attributeDesc, isOutput, root, parent)
|
||||
|
||||
@Slot()
|
||||
def clicked(self):
|
||||
self.node.onAttributeClicked(self)
|
||||
|
||||
class ChoiceParam(Attribute):
|
||||
|
||||
|
|
|
@ -301,6 +301,15 @@ class FloatParam(Param):
|
|||
|
||||
range = Property(VariantList, lambda self: self._range, constant=True)
|
||||
|
||||
class PushButtonParam(Param):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, name, label, description, uid, group='allParams', advanced=False, semantic='', enabled=True, visible=True):
|
||||
super(PushButtonParam, self).__init__(name=name, label=label, description=description, value="", uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled, visible=visible)
|
||||
def validateValue(self, value):
|
||||
pass
|
||||
def checkValueTypes(self):
|
||||
pass
|
||||
|
||||
class ChoiceParam(Param):
|
||||
"""
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue