I implmented a database intensive method where I want to update the user on progress, obviously using a wxProgressDialog dialog. However, the database layer is separate frpm the user interface that initiated that process and being able to update from one to the other has been problematic.
Has anyone else encountered this problem and been able to create a workable solution?
Thanks,
John
wxProgressDialog question
-
- In need of some credit
- Posts: 9
- Joined: Wed Sep 01, 2004 11:45 am
- Location: Minneapolis, MN
-
- I live to help wx-kind
- Posts: 194
- Joined: Mon Aug 30, 2004 1:26 pm
- Location: PA, USA
Re: wxProgressDialog question
Sounds like you're trying (or have) some sort of MVC design in your application. At least, you have an obvious model (the database app), and an obvious view (wxProgressDialog)jdubchak wrote:I implmented a database intensive method where I want to update the user on progress, obviously using a wxProgressDialog dialog. However, the database layer is separate frpm the user interface that initiated that process and being able to update from one to the other has been problematic.
What I would do is probably something like this
Code: Select all
void myControllerObject::DoThatLongThing()
{
for (int i = 0; i > countRecordsToChange; i++)
{
updateRecord(i);
//update my wxProgressBar
}
}
-
- In need of some credit
- Posts: 9
- Joined: Wed Sep 01, 2004 11:45 am
- Location: Minneapolis, MN
Re: wxProgressDialog question
Yes, absolutely. Doesn't everyone?Ryan Wilcox wrote:Sounds like you're trying (or have) some sort of MVC design in your application.
The problem is that the wxProgressDialog expects to be created on the stack as a local variable and you must update it using that locally scoped variable. Which you can't.Ryan Wilcox wrote:At least, you have an obvious model (the database app), and an obvious view (wxProgressDialog)
I've tried both the callback mechanism and custom events - neither of which have proven useful. I think I may have to implement another class which wraps (not extends) the wxProgressDialog in order to get the functionality I want...
Yep, except what you've done here is broken the MVC separation because the model now contains a visual component.Ryan Wilcox wrote:What I would do is probably something like this
Code: Select all
void myControllerObject::DoThatLongThing() { for (int i = 0; i > countRecordsToChange; i++) { updateRecord(i); //update my wxProgressBar } }
Thanks very much.
John
-
- I live to help wx-kind
- Posts: 194
- Joined: Mon Aug 30, 2004 1:26 pm
- Location: PA, USA
Re: wxProgressDialog question
Ryan Wilcox wrote:What I would do is probably something like this
Code: Select all
void myControllerObject::DoThatLongThing() { for (int i = 0; i > countRecordsToChange; i++) { updateRecord(i); //update my wxProgressBar } }
I typoed. I meanJohn wrote: Yep, except what you've done here is broken the MVC separation because the model now contains a visual component.
Code: Select all
myModelObject->UpdateRecord(i);
-
- In need of some credit
- Posts: 9
- Joined: Wed Sep 01, 2004 11:45 am
- Location: Minneapolis, MN
Sorry, a more accurate statement would be: I would prefer two-step construction with wxProgressDialog, similar to many (if not all) of the other wxWidgets Windows.As having to create it on the stack.. Why do you think it requires this?
The disadvantage to the current wxProgressDialog is that the constructor is responsible for showing the dialog, so you can't construct it and show it some point later in the code.
Maybe I'm looking at the problem incorrectly, but I don't see how the current wxProgressDialog can be used effectively with a callback without some code monkeying...
Thanks,
John