Created
February 14, 2012 18:49
-
-
Save barnes7td/1829056 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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