I want my layout to consist of 2 sets of side-by-side visuals, and these sets should be stacked. However, using the code below, I get my first two visualizations side-by-side, and then the third and fourth are stacked, but also part of the side-by-side section.
I tried ending the side-by-side section, but that results in error messages that I "SystemError: Cannot begin a section once the root section has been ended."
layout = LayoutDefinition()
layout.BeginSideBySideSection()
counter = 0
for visual in page.Visuals:
if counter == 2:
layout.BeginStackedSection()
layout.Add(visual)
else:
layout.Add(visual)
counter += 1
layout.EndSection()
layout.EndSection()
page.ApplyLayout(layout)
The rule is that when you start a section, it needs a corresponding end section, a bit like xml.
I would do something like this, unless you have a special reason for using this loop with the counter:
from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Application.Layout import LayoutDefinition
layout = LayoutDefinition()
visuals = list(page.Visuals)
layout.BeginStackedSection()
layout.BeginSideBySideSection()
layout.Add(visuals[0])
layout.Add(visuals[1])
layout.EndSection()
layout.BeginSideBySideSection()
layout.Add(visuals[2])
layout.Add(visuals[3])
layout.EndSection()
layout.EndSection()
page.ApplyLayout(layout)