[wxPython-users] Re: Question about Grid or events ?
Robin Dunn
robin at alldunn.com
Wed Aug 8 14:29:36 PDT 2007
Hugues JEAN-BAPTISTE wrote:
> I have tested the next :
>
> def OnBtVal(self, evt) :
> for row in range(gr.GetNumberRows()) :
> wx.CallAfter(self.ProcRow, row)
> def ProcRow(self, row) :
> Do manythings ....
> gr.SetValue(row, col, 'Row finished ...')
> gr.Refresh()
> wx.Yield()
>
> I have the message :
>
> Traceback (most recent call last):
> File "C:\PYTHON23\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", line
> 13539,
> in <lambda>
> lambda event: event.callable(*event.args, **event.kw) )
> File "..\paie.1.7\calcul.py", line 441, in CalculSal
> wx.Yield()
> File "C:\PYTHON23\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", line
> 7447, i
> n Yield
> return _core_.Yield(*args, **kwargs)
> wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
> ..\..\src\m
> sw\app.cpp(684): wxYield called recursively
>
> I don't understand the problem !...
>
A wx.Yield call happened while another wx.Yield call was already in
progress.
wx.Yield essentially starts a nested event loop, including processing of
pending and idle events. So when you use CallAfter it makes a pending
event, when that event is processed and your function calls wxYield, it
processes the pending events again and eventually gets to the next
wx.Yield call, which processes pending events again which...
Take a look at http://wiki.wxpython.org/LongRunningTasks for ideas on
how to better handle doing things that may take a long time to run.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list