Forum: wxRuby Creating a Progress Bar

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F4387b44a3f17713865d010641d3461b?d=identicon&s=25 Jason Shelton (Guest)
on 2009-01-05 21:46
(Received via mailing list)
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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-01-05 23:34
(Received via mailing list)
Jason Shelton 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
760e5c90000057a6860986b69b77c400?d=identicon&s=25 John Griffiths (indiehead)
on 2009-01-15 14:50
solved a similar problem here...

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

Hope it helps,



John.
This topic is locked and can not be replied to.