如何在 Ruby Shoes 中显示数组的输出?

发布于 2024-12-02 23:05:27 字数 294 浏览 0 评论 0原文

我将此作为我的代码

 openAll = File.open('N:\Josh\Blondie\db.txt')
 allNumbers = Array.new
 allNumbers=[]  
  openAll.each_line {|line|
    allNumbers.push line
  }

  puts allNumbers

,我希望能够使用 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
  }

  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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

渔村楼浪 2024-12-09 23:05:27

下面是将文本输出到鞋子窗口的示例。使用 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

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
雅心素梦 2024-12-09 23:05:27

我想你应该使用方法 Kernel#alert 而不是 Kernel#puts。

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文