Handling an "OnLoad" Frame event

Not sure why setting control values before they're displayed would cause
them to display incorrectly.. but if you want to set their values upon
initialization, but after the first EVT_PAINT event has been processed,
then one way to do that is to make sure there's an EVT_PAINT event in
queue (for example by calling wx.Frame::Show()) and then use
wx.CallAfter() to post an event to call an OnLoad() function, like
this:

class MyFrame(wx.Frame):

  def __init__(..frame init parms.., ..your init parms..):
    wx.Frame.__init__(..frame init parms..)
    self.Show()
    wx.CallAfter(self.OnLoad, ..your init parms..)

  def OnLoad(self, ..your init parms..):
    ..your init code..
    self.Refresh()

In this scenario, OnLoad() is called after the first EVT_SIZE and
EVT_PAINT events are handled, so this would probably work for you.

It seems to me that I've run into the same kind of thing that it sounds
like you're running into, and at the time I concluded that there is some
stuff that wx does during initialization, after the call to
MyFrame.__init__(), and that some things require that initialization to
be completed before they will have the intended effect. That might be
what you're running into, it may not have anything to do with EVT_PAINT
processing. If that's the case, you may not have to put the Show()
command in __init__(), you could just put it at the end of OnLoad() in
place of Refresh().

dcrespo@grupozoom.com 4/4/2006 12:03:28 PM >>>

Hi List,

How can I know if a frame has finished its loading content? My problem
is that I set values to some controls *before* the frame is shown, and
because of this, these values doesn't show properly. I'm talking about
Masked Edit Controls, NumCtrl specifically. So I tried to set its values
after the frame is shown, and it work perfect. The thing is how to
programatically know when a frame is drawn in the screen.

Any help?

Thanks

Daniel