Problem with wx.Yield()

Hi,

Don’t stop the interface and display the value on the progressbar I am
using the wx.Yield(), while my program does the processing. But when I
resize the window the program displays these errors:

File “E:\frame.py”, line 335, in UpdateStatus
wx.Yield()
File “C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx_core.py”, line 7695, in Yield

return _core_.Yield(*args)

wx._core.PyAssertionError: C++ assertion “wxAssertFailure” failed at …\src\msw\app.cpp(703) in wxApp::Yield(): wxYield called recursively
Traceback (most recent call last):
File “E:\test.py”, line 189, in

I am using wxPython 2.8.10.1, with Python 2.6. It’s the same problem in Windows, Linux and Mac OS.

Regards,

Paulo Amorim

Maybe somewhat surprisingly this error is exactly what the error message says it is. :wink: What is happening is that while pending events are being processed in one wx.Yield, a new event is delivered that causes wx.Yield to be called again. This is not allowed.

According to the wx developers using any of the yield functions is a bad idea, and you should find another way to keep the UI updated. Otherwise, you can either prevent the recursion or there is a yield function that will check if it's already in a yield and will just return if so without doing anything. If you'd like to try this then call wx.GetApp().Yield(True) instead.

···

On 11/11/09 7:42 AM, Paulo Henrique Junqueira Amorim wrote:

Hi,

Don't stop the interface and display the value on the progressbar I am
using the wx.Yield(), while my program does the processing. But when I
resize the window the program displays these errors:

   File "E:\frame.py", line 335, in UpdateStatus
     wx.Yield()
   File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 7695, in Yield
     return _core_.Yield(*args)
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at
..\..\src\msw\app.cpp(703) in wxApp::Yield(): wxYield called recursively
Traceback (most recent call last):
   File "E:\test.py", line 189, in <lambda>

I am using wxPython 2.8.10.1, with Python 2.6. It's the same problem in
Windows, Linux and Mac OS.

--
Robin Dunn
Software Craftsman