Forced focus on a wx.Frame.Show()

Is there a way to show a previously hidden frame without having both
EVT_SET_FOCUS and EVT_KILL_FOCUS sent to the participating windows?

Overriding the OnFocus event to set it back to the previous owner via
event.GetWindow().SetFocus() has the aesthetical disadvantage of
making the frames' title bars flicker for a single frame.

-F

Hello Federico,

Overriding the OnFocus event to set it back to the previous owner via
event.GetWindow().SetFocus() has the aesthetical disadvantage of
making the frames' title bars flicker for a single frame.

Well, that seems to me a very small fee to pay... how fast is the
blink of the frame activation? I would say quite fast... however, in
wxWidgets you could (in theory, I have never tried it) override the
AcceptFocus() method of the second frame, but I don't know if this
function can be overridden in wxPython. Probably not, but someone more
knowledgeable than me may have a better answer.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

Andrea Gavana wrote:

Hello Federico,

Overriding the OnFocus event to set it back to the previous owner via
event.GetWindow().SetFocus() has the aesthetical disadvantage of
making the frames' title bars flicker for a single frame.

Well, that seems to me a very small fee to pay... how fast is the
blink of the frame activation? I would say quite fast... however, in
wxWidgets you could (in theory, I have never tried it) override the
AcceptFocus() method of the second frame, but I don't know if this
function can be overridden in wxPython. Probably not, but someone more
knowledgeable than me may have a better answer.

It can't, but it wouldn't help anyway as frames themselves never get the focus. It's always some focusable control within the frame, and when a frame is shown it will try to set focus to a focusable window when it is activated. Probably the best that can be done is to set a flag before showing the other frame that tells the focus event handlers to ignore the event, show the other frame, do a self.Raise to reactivate the current frame (which will set focus back to where it was before) and then clear the flag.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!