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:
vocx-fc
2020-06-06 12:29:50 -05:00
committed by Yorik van Havre
parent bbdd9abcdc
commit 466ae17a4a

View File

@@ -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":