[wxPython-users] Re: Question about Grid or events ?
Hugues JEAN-BAPTISTE
hjb at agorinfo.fr
Wed Aug 8 08:20:50 PDT 2007
Christian K. a écrit :
> Hugues JEAN-BAPTISTE wrote:
>> Hi all,
>>
>> I have to process something for each row of a grid and I want to
>> inform the user progressively (Many lines in the grid).
>> I have tested the next, but, it does not work :
>>
>> def OnBtVal(self, evt) :
>> for row in range(gr.GetNumberRows()) :
>> wx.CallAfter(self.ProcRow, row)
>> wx.CallAfter(gr.Refresh) -> (ForceRefresh, do the same)
>> def ProcRow(self, row) :
>> Do manythings ....
>> gr.SetValue(row, col, 'Row finished ...')
>>
>> The problem is : the grid is refreshed only when all the rows are
>> processed.
>>
>> I thought of having understood, events are in a queue and
>> wx.CallAfter puts events in order in this queue !?...
>
> Exactly, the events are queued until your app is back in the wxpython
> main loop, i.e. when the loop is finished. Then they get processed,
> one after another, which is not what you want. Try calling Refresh()
> directly maybe followed by a wx.Yield().
>
> Christian
Thank you Christian,
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 !...
--
Hugues JEAN-BAPTISTE (hjb at agorinfo.fr)
AGORINFO S.A.S. (http://www.agorinfo.fr)
More information about the wxpython-users
mailing list