Puts up a window containing a progress bar and a button. Clicking on the button, hides the button and starts showing progress in the progress bar. When the progress bar has filled, the button returns and the whole thing can be repeated until you're bored out of your mind 
<code>
#! /usr/bin/ruby -w
# Author: Morton Goldberg
···
#
# Date: August 31, 2006
#
# Progress Indicator
require 'tk'
require 'tkextlib/iwidgets'
DEBUG = []
begin
root = TkRoot.new {title 'Ruby/Tk Progress Indicator'}
fb = Tk::Iwidgets::Feedback.new(root) {
steps 20
labeltext "Click the Button"
barcolor 'red'
barheight 20
troughcolor 'gray90'
}
fb.component_widget('trough').
configure('relief'=>'ridge', 'borderwidth'=>4)
fb.component_widget('bar').
configure('relief'=>'sunken', 'borderwidth'=>4)
fb.pack('fill'=>'x', 'padx'=>15, 'pady'=>10)
btn = TkButton.new(root) {
text "Do Something"
command {btn.action}
}
btn.pack('pady'=>10)
btn.instance_variable_set(:@fb, fb)
def btn.action
unpack
default = @fb.labeltext
@fb.labeltext = "Doing Something ..."
(1..@fb.steps).each do |i|
@fb.step
sleep(0.2)
end
@fb.labeltext = default
@fb.reset
pack('pady'=>10)
end
# Set initial window geometry; i.e., size and placement.
win_w, win_h = 300, 160
# root.minsize(win_w, win_h)
win_l = (TkWinfo.screenwidth('.') - win_w) / 2
root.geometry("#{win_w}x#{win_h}+#{win_l}+50")
# Set resize permissions.
# root.resizable(true, true)
root.resizable(false, false)
# Make Cmnd+Q work as expected.
# root.bind('Command-q') {
# DEBUG << TkWinfo.geometry('.')
# Tk.root.destroy
# }
root.bind('Command-q') {Tk.root.destroy}
Tk.mainloop
ensure
puts DEBUG unless DEBUG.empty?
end
</code>
Regards, Morton