This post originated from an RSS feed registered with Ruby Buzz
by Caleb Tennis.
Original Post: Mixing some GUI elements into your Ruby program
Feed Title: Tarkblog
Feed URL: http://blog.casey-sweat.us/library/shared/happyUrl/fnf_msdn.asp?Redirect="http://blog.casey-sweat.us/404/default.asp"
Feed Description: Caleb's personal weblog about his experiences in life, langauges, and laughter.
In Ruby, when you’ve got to grab some user input, a quick way of doing it is with a gets:
puts "What is your name?"
name = gets
puts "Hi #{name}"
But, we can make the interaction so much more pleasant through QtRuby:
require 'Qt'
Qt::Application.new(ARGV)
ok = Qt::Boolean.new
name = Qt::InputDialog::getText(”My Application”, “Enter your name”,
Qt::LineEdit::Normal, nil, ok)
if(!ok.nil?)
puts “Hi #{name}”
else
raise “The user didn’t [...]