Ruby Shoes GUI: Continually Updating Paragraphs

前端 未结 2 777

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

相关标签:
2条回答
  • 2020-12-21 15:51

    it seems like you need the every method (search for it here). The every method will call your code every second (or as many second as you pass in).

    Should work like this:

    every do
      # your appending code
    end
    

    (might need 1 as an argument, not 100% sure atm)

    0 讨论(0)
  • 2020-12-21 15:56

    If you're looking to list all files in a directory and refresh the list every second, then I think this is what you're looking for:

    Shoes.app do
    
      stack do
        @btn_exit = button("Exit") {exit}
        @log = para "Logging goes here..."
      end
    
      every 1 do
        @log.text = Dir.entries('C:/Test').select{|file| file != "."*file.length}.join("\n")
      end
    
    end
    
    0 讨论(0)
提交回复
热议问题