Enaml Looper 水平布局
Enaml Looper horizontal layout
默认情况下,下面的代码会将每个 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 文档中找不到任何关于此的信息/API。
您可以提供自己的约束来执行您想要的操作,例如 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
默认情况下,下面的代码会将每个 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 文档中找不到任何关于此的信息/API。
您可以提供自己的约束来执行您想要的操作,例如 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