Skip to content

Instantly share code, notes, and snippets.

@rociiu
Created November 21, 2010 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rociiu/708359 to your computer and use it in GitHub Desktop.
Save rociiu/708359 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'hotcocoa'
require 'net/http'
# Replace the following code with your own hotcocoa code
class Application
include HotCocoa
def start
application :name => "My First App" do |app|
app.delegate = self
window :frame => [100, 100, 200, 140], :title => "My First App" do |win|
win << button(:title => "Quit", :frame => [0, 0, 100, 40] , :on_action => proc { exit})
#win << label(:text => "Hello from HotCocoa", :layout => {:start => false})
win << button(:title => "What's GOOG price?", :frame => [0, 10, 150, 40], :on_action => proc {
result = Net::HTTP.get URI.parse("http://download.finance.yahoo.com/d/quotes.csv?s=GOOG&f=snl1c1p2")
goog_price = result.strip.split(',')[2]
alert :message => "GOOG: #{goog_price}"
})
win.will_close { exit }
end
end
end
# file/open
def on_open(menu)
end
# file/new
def on_new(menu)
end
# help menu item
def on_help(menu)
end
# This is commented out, so the minimize menu item is disabled
#def on_minimize(menu)
#end
# window/zoom
def on_zoom(menu)
end
# window/bring_all_to_front
def on_bring_all_to_front(menu)
end
end
Application.new.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment