I made a testing application that demonstrates my assumption of
wx.Frame.Disable() not working as expected.
Run my application and click on the 'Disable frame' button. Then while
the busy cursor is shown, click on the 'Disturb!' button. You will get
a message box right after the busy cursor reverts to the normal one
and after the frame is enabled. Is that by design? I want to suppress
the message box of being propagated after the frame has been enabled.
I don't want that events propagate while the frame is disabled. How
can I do that?
I made a testing application that demonstrates my assumption of
wx.Frame.Disable() not working as expected.
Run my application and click on the 'Disable frame' button. Then while
the busy cursor is shown, click on the 'Disturb!' button. You will get
a message box right after the busy cursor reverts to the normal one
and after the frame is enabled. Is that by design? I want to suppress
the message box of being propagated after the frame has been enabled.
I don't want that events propagate while the frame is disabled. How
can I do that?
1. Use Disable() over the background Panel instead of Frame.
2. Use SafeYied to consume the pending inputs before Enable()
Function time.sleep() should only be used with extreme caution in wxPython because it blocks all wx events, which is usually very unlikely. The sleep() function is for Python apps and was not designed for WX.
Use a wx.Timer() instead. This provides you full control of timing periods.
It is far better to block only only specific events or disable specific controls. See the attached demo app.
I want to suppress
the message box of being propagated after the frame has been enabled.
I don’t want that events propagate while the frame is disabled. How
can I do that?
I found something simpler than wx.Timer(). I found wx.Sleep(). It does
the same thing that time.sleep() does. But if I click on the Disturb
button while the frame or panel is disabled, I get a message box after
the frame or panel is enabled. Having wx.SafeYield(self) after
wx.Sleep(5), the message box is suppressed. I just want to know
whether this is the right way to go?
It really isn't much different than time.sleep(). In fact on Windows they both use the same Windows API under the covers. If you don't care that all events (including repainting the window if it gets damaged) are blocked for the time interval then you can do whatever you want. If you do care then using a timer is the better way to go.
···
On 12/18/10 4:55 AM, Bo�tjan Mejak wrote:
I found something simpler than wx.Timer(). I found wx.Sleep(). It does
the same thing that time.sleep() does. But if I click on the Disturb
button while the frame or panel is disabled, I get a message box after
the frame or panel is enabled. Having wx.SafeYield(self) after
wx.Sleep(5), the message box is suppressed. I just want to know
whether this is the right way to go?