Skip to content

Instantly share code, notes, and snippets.

@barnes7td
Created February 14, 2012 18:49
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 barnes7td/1829056 to your computer and use it in GitHub Desktop.
Save barnes7td/1829056 to your computer and use it in GitHub Desktop.
Shoes.app do
stack do
@console = edit_box
@input = edit_line
@button = button "Ask Name"
end
$stdout = StringIO.new
$stdin = StringIO.new
e = every do |i|
#@console.text = @console.text + "\n" + $stdout.string
@console.text = $stdout.string
$stdin.string = @input.text unless @input.text == nil
flush
#e.stop if
end
keypress do |k|
if k == "\n"
#$stdin.string = @input.text
#$stdin = @input.text
puts @input.text
@input.text = ""
flush
end
end
@button.click do
puts "What is your name?"
@answer = gets
if @answer != nil
@answer = 'Name: ' + @answer.chomp
else
@answer = 'broken'
end
puts @answer
@input.text = ""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment