I'm trying to fill text entries to fill the whole width, which works fine if the entries are put directly to the frame, but if they're put in to a panel, they revert to their default size. Also the 'boxed' layout combinator text disappears. What am I doing wrong?
import Graphics.UI.WX
main = start gui
gui = do
f <- frame []
p <- panel f []
xcoord <- entry p []
ycoord <- entry p []
set p [layout := fill $ boxed "foo" $
grid 5 5 [
[floatRight $ label "x coordinate", hfill $ widget xcoord]
, [floatRight $ label "y coordinate", hfill $ widget ycoord]
]
]
set f [layout := fill $ container p glue]
You're specifying the layout of p in the set p [layout := ...
statement and then throwing it away with the container p glue
usage.
(container
's second parameter is a layout for the container. glue
is a layout, but not a sensible one for a panel.)
You should either (simplest) replace container p glue
with widget p
like this:
import Graphics.UI.WX
main = start gui
gui = do
f <- frame []
p <- panel f []
xcoord <- entry p []
ycoord <- entry p []
set p [layout := boxed "foo" $
grid 5 5 [
[floatRight $ label "x coordinate", hfill $ widget xcoord]
, [floatRight $ label "y coordinate", hfill $ widget ycoord]
]
]
set f [layout := fill $ widget p]
or move all your layout code into the container expresssion at the end:
import Graphics.UI.WX
main = start gui
gui = do
f <- frame []
p <- panel f []
xcoord <- entry p []
ycoord <- entry p []
set f [layout := fill $ container p $ boxed "foo" $
grid 5 5 [
[floatRight $ label "x coordinate", hfill $ widget xcoord]
, [floatRight $ label "y coordinate", hfill $ widget ycoord]
]]
but I prefer the first one, because it feels cleaner to me and seems easier to add more stuff to your main frame f
later.