【发布时间】:2012-09-15 08:25:50
【问题描述】:
我正在尝试使用 wxHaskell。我无法在 ghci 下运行应用程序,所以我必须使用应用程序来测试它。我想用 println 调试来测试程序。但是,putStrLn 似乎在 GUI 中不起作用:
{-# LANGUAGE Haskell2010 #-}
module Main where
import Graphics.UI.WX
drawUI dc view = do
circle dc (point 10 10) 5 [penKind := PenSolid, color := red]
putStrLn "painted"
helloGui :: IO ()
helloGui = do
f <- frame [
text := "Example",
resizeable := False,
bgcolor := white,
layout := space 400 300,
on paint := drawUI]
return ()
main :: IO ()
main = do
putStrLn "Started"
start helloGui
如果我注释掉 start helloGui,一切都会打印好。但是,如果我返回它,则不会打印任何内容,但会显示窗口。这里有什么问题?
【问题讨论】:
-
输出缓冲?关闭窗口后是否立即打印?
-
是的,我用一个打印和刷新的函数来解决这个问题。但是有什么办法可以开启自动刷新?