Renaming Section based on Boolean


I want to rename a Section in my app based on the toggle of a BooleanField:

class Parametrization(ViktorParametrization):
    tab_1.section_1.boolean_field = BooleanField('name')
    if Lookup('tab_1.section_1.boolean_field'):
        tab_2.section_2 = Section('name_if_true')
        tab_2.section_2 = Section('name_if_false)

This always seems to return a section with the name ‘name_if_true’.
Is there a way to change the section names depending on a BooleanField (and some of the attributes inside the section)?

Hi Reinout,

Tab/Section/Field names are static, meaning they cannot depend on params. What you CAN do is making all fields within a Section (in)visible depending on a boolean field. The section will become invisible if all fields within are invisible. You would need 2 sections with the same fields (with opposite visibility) though.

Alternatively, you could use two Text objects and make them visible depending on the boolean. This way you do not need to account for both sections when unpacking the params

I was making assumptions in my last reply