Skip to main content

Creating tabs & sections

In some cases, the parametrization becomes quite big which requires a more structured layout. This can be achieved by making use of a Tab and Section, which represent a tab and collapsible section in the interface respectively.

A 2-layered structure using Tab objects looks like this:

from viktor.parametrization import ViktorParametrization, TextField, NumberField, Tabclass Parametrization(ViktorParametrization):    tab_1 = Tab('Tab 1')    tab_1.input_1 = TextField('This is a text field')    tab_1.input_2 = NumberField('This is a number field')    tab_2 = Tab('Tab 2')    tab_2.input_1 = TextField('Text field in Tab 1')    tab_2.input_2 = NumberField('Number field in Tab 1')

Parametrization with tabs, no sections

Using Section objects results in the following:

from viktor.parametrization import ViktorParametrization, TextField, NumberField, Sectionclass Parametrization(ViktorParametrization):    section_1 = Section('Section 1')    section_1.input_1 = TextField('This is a text field')    section_1.input_2 = NumberField('This is a number field')    section_2 = Section('Section 2')    section_2.input_1 = TextField('Text field in Section 1')    section_2.input_2 = NumberField('Number field in Section 1')

Parametrization with sections, no tabs

A parametrization with a maximum depth of 3 layers consists of Tab, Section, and Field objects:

from viktor.parametrization import ViktorParametrization, TextField, NumberField, Tab, Sectionclass Parametrization(ViktorParametrization):    tab_1 = Tab('Tab 1')    tab_1.section_1 = Section('Section 1')    tab_1.section_1.input_1 = TextField('This is a text field')    tab_1.section_1.input_2 = NumberField('This is a number field')    tab_1.section_2 = Section('Section 2')    ...    tab_2 = Tab('Tab 2')    ...

Parametrization with sections and tabs