2014-06-07 103 views
1

以下簡單佈局在調整大小後不會垂直展開,只能垂直展開。我已經玩過hug_width,hug_height和夥伴沒有成功。我也嘗試使用約束hbox調整MainWindow大小,HGroup不會垂直擴展

我缺少什麼?

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" 

回答

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' 

然而,這種類型的佈局可以很容易地用一個容器來實現。沒有必要對嵌套:

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