0

我想在事件发生后切换布局(即单击按钮)。所以我设置了新的布局并重新绘制了面板,但布局没有改变。(只有在我手动调整框架大小后才会这样做。)缺少什么神奇的酱汁?谢谢你的协助!

import Graphics.UI.WX

buildGUI = do
  f <- frame [ text := "Hello" ]

  controls <- panel f []
  ctext <- staticText controls [ text := "Foo" ]
  butn <- button controls [text := "change layout"]
  set controls [ layout := row 0 [margin 5 (widget ctext),
                                  margin 5 (widget butn) ]]

  set f [ layout := widget controls ]

  set butn [on command := do
      -- switch layout, button first, text second
      set controls [layout := row 0 [ margin 5 (widget butn)
                                    , margin 5 (widget ctext) ]]
  {-
     repaint doesn't do it, but if I resize the frame by hand,
     the layout changes
  -}    
      repaint controls         ]

  return ()

main = start buildGUI
4

1 回答 1

1

在考虑到 MathematicalOrchid 的评论后,我自己找到了答案。该函数被调用refit

于 2015-01-28T17:26:10.003 回答