Skip to content

Instantly share code, notes, and snippets.

@steveklabnik
Created May 25, 2012 04:15
Show Gist options
  • Select an option

  • Save steveklabnik/2785728 to your computer and use it in GitHub Desktop.

Select an option

Save steveklabnik/2785728 to your computer and use it in GitHub Desktop.
Some simple architecture decision options for shoes 4
require 'tk'
class Shoes
module Tk
class App
def initialize
@root = TkRoot.new
end
def button(title, &blk)
b = TkButton.new(@root) do
text title
command &blk
pack
end
end
def alert(text)
::Tk::messageBox :message => text
end
end
end
end
class Shoes
def self.app(&blk)
App.new.instance_eval(&blk)
end
include Shoes::Tk
end
Shoes.app do
button "hello" do
alert "hi"
end
end
Tk.mainloop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment