It seems like I get myself in trouble with re-creating widgets on a thread with a timer :). In the thread, every X seconds, it sets a new dataset and calls wx.CallAfter(…) to do the refresh of the wx GUI with that dataset. The refresh involves the destruction and creation of a few widgets still :|.
On occasion, if the user minimizes the application or the application no longer is visible, or the user locks their computer, the re-creation of the widgets may cause a crash:
wx._core.PyAssertionError: C++ assertion “wxAssertFailure” failed at …\src\msw\control.cpp(159) in wxControl::MSWCreateControl(): CreateWindowEx(“EDIT”, flags=52010080, ex=00000000) failed
Is there a way to ensure that the refresh is safe and will not create such problems? This might be more of a win32 question, but is there a way to determine whether or not an application is visible – such that I could stop the thread from trying the refresh of data when it is not visible?
It shouldn't matter whether the window is visible or not, I wonder if maybe something else may be going wrong and it just doesn't manifest until that point. You can try using IsShown() as I think it also recursively checks that the parent is shown also. But you might be better off trying to isolate the problem in a small sample and then once you understand it better either fixing it or working around it a different way.
···
On 6/21/11 6:43 PM, Stephen Shaw wrote:
Hello all,
It seems like I get myself in trouble with re-creating widgets on a
thread with a timer :). In the thread, every X seconds, it sets a new
dataset and calls wx.CallAfter(...) to do the refresh of the wx GUI with
that dataset. The refresh involves the destruction and creation of a
few widgets still :|.
On occasion, if the user minimizes the application or the application no
longer is visible, or the user locks their computer, the re-creation of
the widgets may cause a crash:
*tc =
wx.TextCtrl(parent,wx.NewId(),data.get(name,''),size=(350,18),style=wx.NO_BORDER)*
*
* File
"C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line
1736, in __init__*
* _controls_.TextCtrl_swiginit(self,_controls_.new_TextCtrl(*args,
**kwargs))*
*wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at
..\..\src\msw\control.cpp(159) in wxControl::MSWCreateControl():
CreateWindowEx("EDIT", flags=52010080, ex=00000000) failed*
Is there a way to ensure that the refresh is safe and will not create
such problems? This might be more of a win32 question, but is there a
way to determine whether or not an application is visible -- such that I
could stop the thread from trying the refresh of data when it is not
visible?