开发者

How can I display the output of an array in Ruby Shoes?

I've got this as my code

 openAll = File.open('N:\Josh\Blondie\db.txt')
 allNumbers = Array.new
 allNumbers=[]  
  openAll.each_line {|line|
    allNumbers.push line开发者_StackOverflow中文版
  }

  puts allNumbers

and I'd like to be able to display the output of this code in a new window with Ruby Shoes, I can't seem to get it to display anything though. The contents of the file are names and phone numbers.

Any ideas?


Here's an example of outputting text to a shoes window. Using a puts statement just outputs to the shell, not to the Shoes app.

Shoes.app :title => "GUI RAW file converter, for the CLI challenged", 
  :resizable => true do 
  background white 
  stack do 
    flow {
      background gray, :height => 30
      caption "Caption", :margin => 8, :stroke => white
      stack {
        para 'This is a fancy line I just printed to the window'
####### Here's an example line you could use to put out the array...
        allNumbers.each do |number|
          para "#{number}"
        end
      }
    }
  end
end


I guess you should use the method Kernel#alert instead of Kernel#puts.

http://shoesrb.com/manual/Built-in.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜