默认情况下,下面的代码将垂直堆叠每个GroupBox对象(一个在另一个下面)。
enamldef Main(Window):
attr model
Container:
constraints = [ hbox(items) ]
Container: items:
Looper:
iterable << model.l # model.l = some list of atom objects
GroupBox:
title << loop_item.name
CheckBox:
checked := loop_item.active
我如何将它们放在一个弯针中,使它们水平堆叠(从左到右)?
我在enaml docs / API中找不到任何相关信息。
答案 0 :(得分:1)
您可以提供自己喜欢的约束,例如hbox帮助: https://github.com/nucleic/enaml/blob/master/examples/layout/basic/hbox.enaml#L34
或者使用其中一个方便的Container子类,比如HGroup: https://github.com/nucleic/enaml/blob/master/examples/widgets/h_group.enaml#L46 https://github.com/nucleic/enaml/blob/master/enaml/widgets/h_group.py#L17
Enaml示例可能会回答您的许多入门级问题: https://github.com/nucleic/enaml/tree/master/examples