2

First, sorry for my language, english is not my native language :-/

I have some troubles using wxpython 2.8/python 2.7 with Windows.

My app using wxPython is quite big now and uses a lot of widgets. My problem is : In a for loop, i open a frame as a variable (myVar = myFrame(...)), and give it some values/variables (like -> myVar.setval('xx', 42)) . Then, it will fill some textareas, grids, etc. from some requests in my database (from the child frame). At the end of the traitment, my child frame generate a pdf file, and print it, then it closes itself with the original self.Destroy() method, not surcharged, of wx.Frame.

A lot of frames are created, one by one, with the same variable (myVar in the example). But, recently, I figured out some issues with more iterations in my loop than usual... With the same configuration (same data with a dump from database), it always crashes at the exact same moment (not on particular data), after a certain number of iteration in my loop.

WxPython uses maximum amount of GDI allowed by Windows (error 1158). In fact my GDI resources from destroyed frames are not released! I read that there's a queue of destroyed objects, waiting to be really killed when no more events are waiting in wxPython and then they are not released because of constant work (the loop). On linux, there is not this issue, everything works fine (but I need it works on Windows). I tried wx.Yield method but nothing changed... I looked threads, but GUI widgets have to be used in wx main loop...

If one of you guys has an idea, it will be wonderful !

[SOLVED] The solution i found is to call wx.Yield() to releases unused ressources. But this only work perfectly on linux. On windows, i need to call wx.Frame.DestroyChildren().

It seems to be OK for now :-)

  • You're getting into some pretty low level stuff here, so you may want to peruse around here for general Python garbage collection methods and read up on [this module](http://docs.python.org/2/library/gc.html) as well – wnnmaw Mar 19 '14 at 16:05
  • [This question](http://stackoverflow.com/questions/4484167/details-how-python-garbage-collection-works) should be useful in your research – wnnmaw Mar 19 '14 at 16:06
  • Unfortunetly, python garbage collector does not collect GDI objects in queue for deletion from wxpython – Paul Laenen Mar 19 '14 at 16:37

1 Answers1

0

OP seemed to find the solution.

The solution I found is to call wx.Yield() to releases unused ressources. But this only work perfectly on linux. On windows, i need to call wx.Frame.DestroyChildren().

ρss
  • 5,115
  • 8
  • 43
  • 73