I want to show a MessageBox after leaving a Text-Entry field.
I have two wx.TextCtrl and each one has wx.EVT_KILL_FOCUS binded to them.
...
If I just print the message to the console it works as expected.
What am I doing wrong?
Focus is a complicated topic. Remember, when you display your message
box, the app itself loses focus. Windows ordinarily will not sent a
WM_KILLFOCUS to a focused control within an app losing focus, but I
believe wx does.
So, I think the processing goes something like this. When you tab out
of text1, it sets the focus to text2 and queues up a "lost focus" event
for text1. During the process of handling that event, you put up a
message box, which causes the newly-focused text2 to get a "lost focus"
event.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
I want to show a MessageBox after leaving a Text-Entry field.
I have two wx.TextCtrl and each one has wx.EVT_KILL_FOCUS binded to them.
...
If I just print the message to the console it works as expected.
What am I doing wrong?
Focus is a complicated topic. Remember, when you display your message
box, the app itself loses focus. Windows ordinarily will not sent a
WM_KILLFOCUS to a focused control within an app losing focus, but I
believe wx does.
So, I think the processing goes something like this. When you tab out
of text1, it sets the focus to text2 and queues up a "lost focus" event
for text1. During the process of handling that event, you put up a
message box, which causes the newly-focused text2 to get a "lost focus"
event.
To solve it you could use:
wx.CallAfter()
function call.
Thank you.
···
On Thu, Aug 25, 2016 at 12:27 PM, Tim Roberts <timr@probo.com> wrote:
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, Aug 25, 2016 at 12:27 PM, Tim Roberts <timr@probo.com> wrote:
Focus is a complicated topic. Remember, when you display your message
box, the app itself loses focus. Windows ordinarily will not sent a
WM_KILLFOCUS to a focused control within an app losing focus, but I
believe wx does.
So, I think the processing goes something like this. When you tab out
of text1, it sets the focus to text2 and queues up a "lost focus" event
for text1. During the process of handling that event, you put up a
message box, which causes the newly-focused text2 to get a "lost focus"
event.
To solve it you could use:
wx.CallAfter()
function call.
I don't see how that changes anything. He'll still get a "lost focus"
event when the message box comes up. I'm afraid the real answer is that
he'll need to manage more state. Like, only issue the message box if
the text field was changed since it got focus.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.