Reputation: 2305
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?
Upvotes: 1
Views: 536
Reputation: 2694
If you are on a Mac and just wish to open safari
You can write the following:
require 'uri'
Shoes.app do
background "#EFC"
border("#BE8",
strokewidth: 6)
stack(margin: 12) do
para "Enter your name"
flow do
@value = edit_box
button "OK", width: 200, height: 200 do
system("open -a safari https://www.biblegateway.com/passage/?search=" + URI::encode(@value.text))
end
end
end
end
Upvotes: 0
Reputation: 42192
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
Upvotes: 0