wxWindow::Update
... Use Refresh first if you want to immediately redraw the window
unconditionally.
wxWindow::Refresh
... if you need to update the window immediately you should use Update
instead.
I have a loop that reads in a file line at a time and does some
processing with each line. After each line I would like to return to
the event loop so the rest of the application can run and just have a
progress indicator somewhere letting the user know how long until the
file is done being processed.
I am assuming this isn't the proper way to process a long job, but if
anyone can point me in the right direction it would be appriciated. I
don't have any problem reading a tutorial, or reviewing sample code
somewhere that addresses an issue similar to this, I just don't really
know where to start.
P.S: Is there a progress bar of any kind in wxWidgets? I didn't see one
listed in the API documentation.
-Micah Caldwell
Update will only immediately repaint invalidated areas, whereas Refresh
tells wxWidgets you want the entire window redrawn (but won't do so until
idle time). If you want to repaint the entire window *now* you would use:
Refresh();
Update();
But if it was OK to repaint the entire window the next time there's idle
time, you could use just Refresh();
If the job will finish quickly, you can use wxYield or one if its brothers
to give other events (most importantly repaints) a chance to run. If it's a
longer job, running several seconds, you may want to consider a thread.
wxGauge is the progress bar.
Kevin
It takes 5-10 seconds to fully process the file. I originaly was
looking in to threading to do the job but while reading the
Multithreading Overview I noticed:
"...but in [other situations] [threading] might be a very poor choice
(example: launching a separate thread when doing a long computation to
show a progress dialog)..."
Instead, it suggests using Update() or the idle event handler. Update I
can't seem to get working and I would rather not do my processing on
idle because I do want it to have priority over other tasks.
Basically, I just want a progress bar that fills up (or a text field
that counts up) while the file is being processed.
-Micah Caldwell
> I tried the following inside a member of wxFrame:
> for(line = file.GetFirstLine(); !file.Eof(); line =
> file.GetNextLine())
> { LineFromFile(line);
> Refresh();
> Update();
> }
> While it was processing the file the window was not getting redrawn.
Until 2.5.5 Update() wasn't recursive so if you don't use 2.5.5 you want
to try it.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/