我正在使用wxHaskell在窗口中显示完整的图像。我的代码是:
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 []无论如何,当应用程序运行时,什么都不会显示(甚至不显示窗口的边框)。我怎么才能让它工作呢?
发布于 2015-11-14 07:24:42
您在widget imagep之前遗漏了一个fill,其效果是您在图片中绘制的面板没有获得任何曲面。我也建议你设置一个outerSize。您可能还想看看https://github.com/wxHaskell/wxHaskell/blob/master/samples/wx/ImageViewer.hs以获得灵感。祝好运!
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 $ fill $ widget imagep
, outerSize := sz 500 500
]
where
onPaint image dc rect = drawBitmap dc image pointZero True []https://stackoverflow.com/questions/30958706
复制相似问题