1

以下简单布局在调整大小后不会垂直扩展,只会垂直扩展。我已经玩过hug_widthhug_height和合作伙伴没有成功。我也尝试使用约束hbox

我错过了什么?

from enaml.widgets.api import MPLCanvas, MainWindow, HGroup, VGroup, CheckBox
enamldef PumpProbeViewer(MainWindow):
    HGroup:
        align_widths = False
        MPLCanvas: plot_wid:
            figure = Figure()
        VGroup: control:
            CheckBox:
                text = "Show current"
            CheckBox:
                text = "Show mean"
            CheckBox:
                text = "Show first detector"
4

1 回答 1

2

垂直大小受 VGroup 限制,因为复选框不能垂直扩展。您需要在 VGroup 中添加一个尾随间隔,以便它可以扩展:

enamldef Main(Window):
    HGroup:
        align_widths = False
        MPLCanvas:
            figure = Figure()
        VGroup:
            padding = 0
            trailing_spacer = spacer
            CheckBox:
                text = 'foo'
            CheckBox:
                text = 'bar'
            CheckBox:
                text = 'baz'

但是,这种类型的布局可以通过单个 Container 轻松实现。不需要嵌套:

enamldef Main(Window):
    Container:
        constraints = [
            hbox(mpl, vbox(cb1, cb2, cb3, spacer))
        ]
        MPLCanvas: mpl:
            figure = Figure()
        CheckBox: cb1:
            text = 'foo'
        CheckBox: cb2:
            text = 'bar'
        CheckBox: cb3:
            text = 'baz'

对于这些类型的问题,您也可以考虑访问 Enaml 小组: https ://groups.google.com/forum/#!forum/enaml

于 2014-06-07T16:39:44.610 回答