Draft: hide properties not used in the Label object
When `LabelType` is `'Custom'`, the `Target` property is hidden and `CustomText` is shown. For other values of `LabelType`, `Target` is shown, and in turn `CustomText` is hidden. This avoids showing unused information in the property editor.
This commit is contained in:
@@ -229,6 +229,22 @@ class Label(DraftAnnotation):
|
||||
"""
|
||||
super(Label, self).onDocumentRestored(obj)
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
"""Execute when a property is changed."""
|
||||
super(Label, self).onChanged(obj, prop)
|
||||
self.show_and_hide(obj, prop)
|
||||
|
||||
def show_and_hide(self, obj, prop):
|
||||
"""Show and hide the properties depending on the touched property."""
|
||||
# The minus sign removes the Hidden property (show)
|
||||
if prop == "LabelType":
|
||||
if obj.LabelType != "Custom":
|
||||
obj.setPropertyStatus("CustomText", "Hidden")
|
||||
obj.setPropertyStatus("Target", "-Hidden")
|
||||
else:
|
||||
obj.setPropertyStatus("CustomText", "-Hidden")
|
||||
obj.setPropertyStatus("Target", "Hidden")
|
||||
|
||||
def execute(self, obj):
|
||||
"""Execute when the object is created or recomputed."""
|
||||
if obj.StraightDirection != "Custom":
|
||||
|
||||
Reference in New Issue
Block a user