[Haskell-beginners] gtk2hs and threadDelay
gabre at caesar.elte.hu
gabre at caesar.elte.hu
Mon Dec 26 14:24:52 CET 2011
Hello!
I managed to do it with timeoutAdd:
--code below is the onClicked function:
drawProgram gui preprocPrg = do
let drArea = (drawWin gui)
drw <- widgetGetDrawWindow drArea
-- let list = compileToList preprocPrg
-- renderWithDrawable drw (drawFromList list)
renderWithDrawable drw (myDraw 200 200)
-- drawWindowProcessUpdates drw True
timeoutAdd ((\_ -> do
renderWithDrawable drw (myDraw2 200 200)
return False) 5) 500
return ()
But "sometimes" it gives the following error:
(<interactive>:23929): Gdk-WARNING **: Using Cairo rendering requires
the drawable argument to
have a specified colormap. All windows have a colormap,
however, pixmaps only have colormap by default if they
were created with a non-NULL window argument. Otherwise
a colormap must be set on them with gdk_drawable_set_colormap
(<interactive>:23929): Gdk-CRITICAL **: IA__gdk_cairo_region:
assertion `region != NULL' failed
<interactive>: user error (NULL pointer)
<interactive>: interrupted
<interactive>: warning: too many hs_exit()s
What can cause this? I think the other parts of my program are
correct, and I cant understand, how can ghci "randomly give" this
error. (every 5. try)
To be honest, my goal is to make a "turtle graphics" program, so I ll
have to write a function, which draws a line on the GUI in slow
motion: there will be even more problems with timing, because I ll
have to draw the line pixel by pixel.
More information about the Beginners
mailing list