Smaller or larger instead of Is(Not)Equal for visibility


Is there a way to make a field visible when another field is smaller or larger than a particular value? In my case, I only want to make field 2 visible when field 1 is smaller than 7.


Hi Marieke,

Good question, and yes this is very much possible.

You can make use of a “call-back function”. A minimum working example of what you’re trying to do would look something like:

from viktor.parametrization import NumberField, Parametrization, Text, FunctionLookup, Lookup

def height_threshold(height, **kwargs):
    if height > 40:
        return True
    return False

class Parametrization(Parametrization):

    length = NumberField('Length (L)', suffix='mm', default=10)
    width = NumberField('Width (W)', suffix='mm', default=10)
    height = NumberField('Height (H)', suffix='mm', default=10)

    text = Text("Your height is getting quite disproportional!!!", visible=FunctionLookup(height_threshold, Lookup("height")))

Let me know if that helps!

It works, thanks! :slight_smile: