I want to switch layouts after an event (ie click on button). So I set the new layout and repaint the panel, but the layout doesn't change. (It does so only after I resize the frame by hand.) What's the magic sauce that's missing? Thank's for helping me out!
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
I found the answer myself after googeling with MathematicalOrchid's comment in mind. The function is called refit
.