Hello, I’m currently developing the GUI part of an application using wxPython. As part of this development I’m writing test to check that values are correctly set, retrieved and so on. I’m using the python unittest framework, where I create the main frame in setUp() and delete it in tearDown(). As the number of tests grew I suddenly got a problem were the program would crash due to a failure to create a new wxPython object.
After searching around on the net on this mail list and elsewere I realised it was probably due to my program not releasing its allocated GDI handles after each test. A look in task manager confirmed this as the GDI numer would rise until it hit 10.000 and the program crashed. In order to localize the problem I have written a small test program where I provoke the error to happen. The test program will run for about 10.000 iterations before I get the error. This is what it looks like:
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
F.
test_gui_example.py (756 Bytes)
···
======================================================================
FAIL: test_1 (main.GuiTest)
Traceback (most recent call last):
File “C:\workspace\test\test_gui_example.py”, line 20, in test_1
self.set_up()
File “C:\workspace\test\test_gui_example.py”, line 7, in set_up
self.frame = GuiFrame(None)
File “C:\workspace\test\test_gui_example.py”, line 31, in init
self.button = wx.Button(self.panel)
File “C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_controls.py”, line 87, in init
controls.Button_swiginit(self,controls.new_Button(*args, **kwargs))
PyAssertionError: C++ assertion “wxAssertFailure” failed at …\src\msw\control.cpp(159) in wxControl::MSWCreateControl(): CreateWindowEx(“BUTTON”, flags=56010000, ex=00000000) failed
Ran 2 tests in 20.101s
FAILED (failures=1)
If I comment out the line self.frame.DestroyChildren the program will only run for about 3000 iterations. In my real application I get a crash after 27 tests. It seems to me that the GDI handle of the frame is not properly released. Could someone help me with this problem?
I’m using Python 2.7.3, with wx 2.8 in Eclipse SDK 3.7.2
greetings
Mads Nilsson