I am using wxHaskell to display a full image in a window. My code is:
import Graphics.UI.WX
import Graphics.UI.WXCore
main :: IO ()
main = start testimg
testimg :: IO ()
testimg = do
f <- frame [text := "Test Image"]
p <- panel f []
image <- bitmapCreateFromFile "landscape.png"
imagep <- panel p [ on paint := onPaint image ]
set f [ layout:= fill $ container p $ widget imagep ]
where
onPaint image dc rect = drawBitmap dc image pointZero True []
Anyway when the app runs nothing is displayed (not even the window's borders). How can I make it work?
You missed a
fill
beforewidget imagep
with the effect that the panel you paint in the picture doesn't get any surface. And I'd recommend setting an outerSize, too. You might also want to have a look at https://github.com/wxHaskell/wxHaskell/blob/master/samples/wx/ImageViewer.hs for inspiration. Good luck!