Is it possible to open a browser window in Ruby Sh

2019-07-27 22:31发布

I'm wanting to build a GUI for a Ruby application I maintain using Shoes, but one of the things I'd like to do is be able to display network graphs using the D3 javascript library. After some Googling, I presume it's not possible to embed javascript in a Shoes app. Does anyone know if it's possible to open a browser window from a Shoes app, or better yet embed a browser window within a window in my Shoes app?

1条回答
劫难
2楼-- · 2019-07-27 23:06

Sure, you didn't mension the color of shoes so i'll use my favorite, green shoes

require 'green_shoes'

Shoes.app do
  gem 'watir'
  chrome_proc = Proc.new {
    require 'watir'
    browser = Watir::Browser.new :chrome
    browser.goto("http://www.google.com")
  }
  para link("Go to google", &chrome_proc)
end

Embedding a browser window.. I wish it could but i'd be suprised.. But you could use watir (html) as your gui all the way.

Here another way based on your comment, this is on windows but i'm sure you will know how to tranpose this to a Mac.

require 'green_shoes'

Shoes.app do
  proc = Proc.new {
    system('"C:\Users\Gebruiker\AppData\Local\Google\Chrome\Application\chrome.exe" http://www.google.be')
  }
  para link("Go to google", &proc)
end
查看更多
登录 后发表回答