"Connecting"-animation with wxAnimation

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
neosoffo
In need of some credit
In need of some credit
Posts: 8
Joined: Wed Oct 26, 2011 12:00 pm

"Connecting"-animation with wxAnimation

Post by neosoffo »

Hey there,

I'm looking for the best solution for my problem, since I don't really get the proper usage of wxAnimation or wxAnomationCtrl from the docs. I have a method to get connected to a server and browse its content. Since this takes a while I wanted to add an animation to show the user that the program's still browsing (otherwise the user might think there's something wrong with my program).
What is the best way to realize this? Creating a new frame with a wxAnimationCtrl?

This is how it's supposed to work:

Code: Select all

void ServerData::connect()
{

    printf("connect()\n");

	/* Animation starts before connecting to Server */


    /********************************************************************* 
     Connect to OPC UA Server
    **********************************************************************/
    /* Some methods for connecting and browsing are now being called */
   
    /*After connecting and browsing the animation is supposed to stop */

}
Now, I am not really sure wether I should create a new frame with a Ctrl in it or if it's possible (or maybe even better) to show my animation otherwise or how it's done commonly...

Thank you in advance!

Forgot to mention I use wxWidgets 2.8.11 on Ubuntu :oops:
catalyn269
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Dec 12, 2007 2:40 pm
Contact:

Re: "Connecting"-animation with wxAnimation

Post by catalyn269 »

I don't think this is the best solution, but here's what I did to help pass time during a long processing job :

1. I used wxThread and wxThread::Entry() for the long task,

2. The user clicked a button which started the long task, I caught the event in the GUI event loop,
- I disabled the controls in the main window,
- I popped up a non modal window (always on top) showing the wxAnimationCtrl,
- I started the worker thread,

3. The worker thread sent events about it's advancement, which were used to increment a progress bar,

4. The worker thread signaled it's termination through an event that is processed as before in the GUI event loop
- tested the worker thread finished properly
- updated the GUI with the results.
- I closed the window with the wxAnimationCtrl
- renabled the controls in the main window

Hope this helps !
Just me!
neosoffo
In need of some credit
In need of some credit
Posts: 8
Joined: Wed Oct 26, 2011 12:00 pm

Re: "Connecting"-animation with wxAnimation

Post by neosoffo »

Thanks I'll try it this way. :)
catalyn269
Experienced Solver
Experienced Solver
Posts: 66
Joined: Wed Dec 12, 2007 2:40 pm
Contact:

Re: "Connecting"-animation with wxAnimation

Post by catalyn269 »

I don't know what your need are exactly, but you should look into wxThreadHelper to ease information sharing.
Also the wxThread has quite a good example of how to handle threads ending either because of their finishing processing or because the user requests the app to close !
Just me!
Post Reply