调整MainWindow的大小,Group不会垂直扩展

时间:2014-06-07 12:46:26

标签: python enaml

以下简单布局在调整大小后不会垂直展开。我已经和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"

1 个答案:

答案 0 :(得分: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