Replies: 4 comments 2 replies
-
Using update to set the list of possible values is a bit weird, I didn't understand why FreeCAD API uses that approach: obj.prop = options # if is a list, sets the options
obj.prop = actual_value # if is not a list, sets the actual value I think that is a confusing API. I propose something different: @proxy(...)
class MyProxy(DataProxy):
prop, prop_meta = PropertyOptions(..., meta=True)
def on_execute(self, event):
# change options dynamically if wanted
self.prop_meta.options = [....] The rationale: prop_meta.enum = ... It provides separated and clear APIs for the property value and the property attributes and also allows to have a nice code completion. What do you think? -- About passing DocumentObject to the options callable, it sounds fair, I will introduce it as an optional parameter. |
Beta Was this translation helpful? Give feedback.
-
Hello @galou |
Beta Was this translation helpful? Give feedback.
-
Hello @galou |
Beta Was this translation helpful? Give feedback.
-
merged into devel branch |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@mnesarco Don't you think it'd good to allow the
Discussions
tab on Github?I'd like to ask how to deal with an enumeration property with a dynamic list of potential values.
PropertyOptions
allows a one-time dynamic list butProperty.options
doesn't take any argument. I think, it should take the FreeCAD object as argument. Other properties may not be initialized but they may not be needed and this can be checked forProperty.update
treats theself.enum
case but not theself.options
)PropertyEnumeration
should work with a custom class forenum
thanks to duck-typing but a checkif isinstance(value, Enum)
inProperty.update()
should be added to allow to update the list of potential values.I tried both options (with modifications in
fpo
) but didn't succeed so far. Anyway, how would you do it?Beta Was this translation helpful? Give feedback.
All reactions