mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-31 18:06:31 +02:00
[core] Add support for lambda function in Attribute desc value
Allows to dynamically configure the default value of the Attribute in python.
This commit is contained in:
parent
05a93c28a2
commit
bbc56cfb31
2 changed files with 7 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
|||
import collections
|
||||
import re
|
||||
import weakref
|
||||
import types
|
||||
|
||||
from meshroom.common import BaseObject, Property, Variant, Signal, ListModel, DictModel, Slot
|
||||
from meshroom.core import desc, pyCompatibility, hashValue
|
||||
|
@ -189,7 +190,7 @@ class Attribute(BaseObject):
|
|||
if self.isLink:
|
||||
return self.getLinkParam().asLinkExpr()
|
||||
if self.isOutput:
|
||||
return self.desc.value
|
||||
return self.defaultValue()
|
||||
return self._value
|
||||
|
||||
def getValueStr(self):
|
||||
|
@ -201,6 +202,8 @@ class Attribute(BaseObject):
|
|||
return str(self.value)
|
||||
|
||||
def defaultValue(self):
|
||||
if isinstance(self.desc.value, types.FunctionType):
|
||||
return self.desc.value(self)
|
||||
return self.desc.value
|
||||
|
||||
def _isDefault(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue