The Shoes GUI kit for Ruby seems like a really nice and easy way to add a GUI to my various scripts, but after banging my head against it, I can't seem to make a paragraph be continually updated with a loop.
Here's my minimal code to show what I'm trying to do:
Shoes.app do
stack do
@exit = button "Exit"
@log = stack { para "Logging goes here..." }
@exit.click { exit }
end
loop do
sleep 1
contents = `ls`
@log.append { para contents }
end
end
But this just blocks forever and my GUI never shows up until I kill the ruby process, at which time all my info appears.
I've tried putting the "contents" checking loop and append in a separate class, in its own "stack" or "flow" loop, tried passing @log to a separate class's method as per the "Block Redirection" header in the Shoes Rules (http://shoesrb.com/manual/Rules.html), still no joy after trying everything I can think of. Any ideas how I can get this working? I'm thinking I just don't have a complete grasp on how Shoes sets up the GUI.