我已将此作为我的代码
openAll = File.open('N:\Josh\Blondie\db.txt')
allNumbers = Array.new
allNumbers=[]
openAll.each_line {|line|
allNumbers.push line
}
puts allNumbers
我希望能够在Ruby Shoes的新窗口中显示此代码的输出,但我似乎无法显示任何内容。该文件的内容是姓名和电话号码。
有什么想法吗?
答案 0 :(得分:2)
以下是将文字输出到鞋子窗口的示例。使用puts
语句只输出到shell,而不是Shoes应用程序。
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
答案 1 :(得分:0)
我猜你应该使用方法Kernel#alert而不是Kernel#puts。