# Feedback \[incr Widget\]

**URL:** <https://www.ruby-forum.com/t/feedback-incr-widget/67647>\
**Category:** Ruby\
**Created:** [September 5, 2006, 9:36pm UTC](https://www.ruby-forum.com/t/feedback-incr-widget/67647 "2006-09-05T21:36:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morton\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dfb087/32.png) [@Morton\_G](https://www.ruby-forum.com/u/Morton_G)\
**Post date:** [September 5, 2006, 9:36pm UTC](https://www.ruby-forum.com/t/feedback-incr-widget/67647/1 "2006-09-05T21:36:25Z")

</div>

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 🙂

`
#! /usr/bin/ruby -w
# Author: Morton G.
#
# 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 ..."
   (removed_email_address@domain.invalid).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
`

Regards, Morton
