example for modal progress bar

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
zmau
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jun 15, 2016 11:41 am

example for modal progress bar

Post by zmau » Mon Apr 15, 2019 1:42 pm

Hello all,
I have a dialog.
One of the buttons should launch an algorithm that takes time, so I want to display a progress bar.
There are many buttons on the dialog, and pressing them would interfere, so I do not want the user to be able to press any button during this process/algorithm. For this reason, I thought that the progress bar should be modal.
1) Is there a code example for what I need to implement ? Anything close to what I need to implement ?
2) Any advice on what is the best way to implement this ?

Thanks
zmau

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 297
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: example for modal progress bar

Post by New Pagodi » Mon Apr 15, 2019 2:05 pm

It sounds like what you want is the wxProgressDialog class. There is a short example this page and larger example in the dialogs sample.

zmau
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jun 15, 2016 11:41 am

Re: example for modal progress bar

Post by zmau » Mon Apr 15, 2019 2:17 pm

Thanks
1) Where is "dialogs sample" ? I think I need the "larger example".
2) I forgot to mention that the algorithm takes place in a different thread, so the short example is not good enough.

Thanks
zmau

User avatar
doublemax
Moderator
Moderator
Posts: 13600
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: example for modal progress bar

Post by doublemax » Mon Apr 15, 2019 2:28 pm

zmau wrote:
Mon Apr 15, 2019 2:17 pm
2) I forgot to mention that the algorithm takes place in a different thread, so the short example is not good enough.
Check the "threads" sample. It's in <wxdir>/samples/thread/
Use the source, Luke!

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 297
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: example for modal progress bar

Post by New Pagodi » Mon Apr 15, 2019 2:30 pm

The dialogs sample is in the samples folder that comes with the wxWidgets library - specifically in the folder <WXROOT>/samples/dialogs. If you're using a separate worker thread, it's very important that you never call gui methods from the secondary thread. So you'll have to update the progress dialog using wxThread event if your using the wxWidgets threading API.

Post Reply