Creating a Progress Bar

All,

I am attempting to add a progress bar to my application. What is
prompting the progress bar to be displayed is the pressing of a button.
This button performs an action, and for the sake of an example, lets say
that it is printing one million words to the screen. While these words
are printing to the screen, I want a progress bar to be running. I want
the bar to fill completely, then go blank, and fill completely over and
over again until all of the words are printed to the screen. Once all
of the words are printed, I want the progress bar to stop its routine. I
have the progress bar up and running, but my problem is that I am using
a while loop to continuously fill the bar, so in turn it is running
infinitely, and the code that comes after it, the words printing, is
never being executed. I can elaborate if necessary. Thanks in advance
for all of your assistance.

  • Shelton

Jason S. wrote:

I guess you mean ProgressDialog or Gauge. They will both do roughly the
same thing, but the former will display it in a standalone dialog.

I am attempting to add a progress bar to my application. What is
prompting the progress bar to be displayed is the pressing of a
button. This button performs an action, and for the sake of an
example, lets say that it is printing one million words to the
screen. While these words are printing to the screen, I want a
progress bar to be running. I want the bar to fill completely, then
go blank, and fill completely over and over again until all of the
words are printed to the screen. Once all of the words are printed, I
want the progress bar to stop its routine.

Use the ‘maximum’ argument of ProgressDialog to set how many steps there
are to progress through. In your case, it might be the number of words.
Use the #update method to set how many steps have been completed. The
dialog is automatically dismissed when the full number of steps is
finished, or call #close to finish it early.

It works the same with Gauge, except you use #value= to set how many
steps have been done.

I have the progress bar up and running, but my problem is that I am
using a while loop to continuously fill the bar, so in turn it is
running infinitely, and the code that comes after it, the words
printing, is never being executed.

Well, don’t use an infinite while loop… either call break somewhere in
the loop to exit it, or use an ‘each’ loop over the right number of
items.

If that’s not it, perhaps describe your question more clearly, and if
possible show a little sample of code that you’re working on.

a

solved a similar problem here…

http://www.ruby-forum.com/topic/175626

Hope it helps,

John.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs