I am just starting to learn wxWidgets (and Python), and have a design
question. I'm very new to this, so if I am way off base, please don't
hesitate to point it out!
I have built my first GUI application, making use of wxFrames. At the
start, it must do some initialisation work which is non-visual. This
takes a few seconds.
Rather than have an apparent delay at application start up, I have
created another wxFrame to behave as a splash screen. I put up the splash
screen at the start, then immediately do the initialisation stuff.
This is achieved by handling EVT_IDLE of the splash frame (the first time
it is raised), and in the event handler, instantiating my initialising
class, which does the necessary work. Then I do a self.Hide() and a
MainFrame.Show().
It works, but is it a reasonable approach, or is it hacky and messy? If
there is a better way, a brief pointer or two would be greatly
appreciated. I got the idea by googling for the (apparently non existent)
"EVT_OPEN".
You might like to take a look at advancedsplash in the advanced generic
widgets part of the documents and demo package.
Gadget/Steve
···
On 31/12/2011 11:34 AM, Walter Hurry wrote:
I am just starting to learn wxWidgets (and Python), and have a design
question. I'm very new to this, so if I am way off base, please don't
hesitate to point it out!
I have built my first GUI application, making use of wxFrames. At the
start, it must do some initialisation work which is non-visual. This
takes a few seconds.
Rather than have an apparent delay at application start up, I have
created another wxFrame to behave as a splash screen. I put up the splash
screen at the start, then immediately do the initialisation stuff.
This is achieved by handling EVT_IDLE of the splash frame (the first time
it is raised), and in the event handler, instantiating my initialising
class, which does the necessary work. Then I do a self.Hide() and a
MainFrame.Show().
It works, but is it a reasonable approach, or is it hacky and messy? If
there is a better way, a brief pointer or two would be greatly
appreciated. I got the idea by googling for the (apparently non existent)
"EVT_OPEN".
I am just starting to learn wxWidgets (and Python), and have a design
question. I'm very new to this, so if I am way off base, please don't
hesitate to point it out!
I have built my first GUI application, making use of wxFrames. At the
start, it must do some initialisation work which is non-visual. This
takes a few seconds.
Rather than have an apparent delay at application start up, I have
created another wxFrame to behave as a splash screen. I put up the splash
screen at the start, then immediately do the initialisation stuff.
This is achieved by handling EVT_IDLE of the splash frame (the first time
it is raised), and in the event handler, instantiating my initialising
class, which does the necessary work. Then I do a self.Hide() and a
MainFrame.Show().
It works, but is it a reasonable approach, or is it hacky and messy? If
It's not too bad. Another idea would be to put the time consuming code (but not any UI code) into another thread. That way the main event loop in the GUI thread can stay alive and respond to paint events or etc. When the thread is done it can call a function/method in the GUI thread using wx.CallAfter that will create the main frame and hide/close the splash.
there is a better way, a brief pointer or two would be greatly
appreciated. I got the idea by googling for the (apparently non existent)
"EVT_OPEN".
Thanks.
You might like to take a look at advancedsplash in the advanced generic
widgets part of the documents and demo package.
And there is also wx.SplashScreen (which is the one used in the demo) if you don't need the fancy abilities of the advanced splash. Either way there is no need to reinvent this wheel.