areal2d
1
Hi, I’m trying to create a StackLayout with a VLayout inside, but the following code just creates an empty window:
(
w = Window()
.layout_(
StackLayout(
VLayout(StaticText().string_("A"), StaticText().string_("B")),
VLayout(StaticText().string_("C"), StaticText().string_("D"))
)
)
.front;
)
I would have expected that StackLayout can be combined in the same manner as VLayout with HLayout:
(
w = Window()
.layout_(
HLayout(
VLayout(StaticText().string_("A"), StaticText().string_("B")),
VLayout(StaticText().string_("C"), StaticText().string_("D"))
)
)
.front;
)
shiihs
2
This seems to be a documented limitation of StackLayout:
StackLayout.new( … views)
Creates a StackLayout and fills it with the items given as arguments. The first view becomes the current one, i.e. visible and on top of others.
Arguments:
… views A sequence of views. Unlike other layouts, StackLayout can not contain another layout.
1 Like
As long as your layouts are contained within views you can add them to the StackLayout
(
w = Window()
.layout_(
StackLayout(
View().layout_(VLayout(StaticText().string_("A"), StaticText().string_("B"))),
View().layout_(VLayout(StaticText().string_("C"), StaticText().string_("D")))
)
)
.front;
)
1 Like
shiihs
4
ouch…now that you mention this, I’ve actually used this “trick” in the past, I must be getting old…
1 Like
areal2d
5
Perfect, this works for me! Thanks a lot!