Resource limits in wxPython/wxWidgets ?

Hi,

I'm building a wxPython application that is a wxNotebook with (so far)
40 tabs. Each tab has about 200 controls, mostly wxCheckBox,
wxTextCtrl, and wxStaticText.

At this size, the app fails with the stack trace below. Mostly it
fails in a call to wxCheckBox() (there are more of them) but it will
also fail like this in wxTextCtrl() (example below) or wxStaticText().

If I remove/add controls earlier in the sequence it just fails later/
earlier at the end.

Any help, please ?

Thanks,

Mike

···

================

Windows XP,
Python 2.3.2 (#49, Oct 2 2003, 20:02:00)
  [MSC v.1200 32 bit (Intel)] on win32,
wxVERSION_STRING = '2.4.2.4'

================

Traceback (most recent call last):
  File "FWSEngine.py", line 190, in ?
    main()
  File "FWSEngine.py", line 172, in main
    exec (expr)
  File "<string>", line 1, in ?
  File "FWSEngine.py", line 50, in putCategoriesLex
    self.putCategory ( cat )
  File "FWSEngine.py", line 81, in putCategory
    self.putCategoryFromColumns (cols)
  File "FWSEngine.py", line 95, in putCategoryFromColumns
    self.putLabeledCoreChoice (label, ccid)
  File "FWSEngine.py", line 106, in putLabeledCoreChoice
    self.TF.putLabeledChoiceByType ( label, items, ctype, notess)
  File "r:\Mello-et-al\FWSTopFrame.py", line 455, in putLabeledChoiceByType
    items, ctype, notess)
  File "r:\Mello-et-al\FWSPanel.py", line 280, in putLabeledChoiceByType
    if ctype == "C": self.putConditionChoiceItems (items, label, notess)
  File "r:\Mello-et-al\FWSPanel.py", line 297, in putConditionChoiceItems
    w = self._ccBoxLabelAndItems (label, items, otherItems, notess)
  File "r:\Mello-et-al\FWSPanel.py", line 345, in _ccBoxLabelAndItems
    y4 = self._ccGridPointsOthers (pnl, ccP["X00"], max (y2, y3), otherItems)
  File "r:\Mello-et-al\FWSPanel.py", line 421, in _ccGridPointsOthers
    self._ccwx4CheckBoxes (pnl, wxPoint(x0, y+2), oItem, tbPos, tbSize)
  File "r:\Mello-et-al\FWSPanel.py", line 474, in _ccwx4CheckBoxes
    tb = wxTextCtrl ( pnl, cID, label, tbPos, tbSize )
  File "C:\Python23\lib\site-packages\wxPython\controls.py", line 777, in __init__
    self.this = controlsc.new_wxTextCtrl(*_args,**_kwargs)

wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed
in e:\Projects\wx2.4\src\msw\control.cpp(134): something is very wrong

09:24:22: Debug: e:\Projects\wx2.4\src\msw\app.cpp(439): 'UnregisterClass(canvas)'
failed with error 0x00000584 (class still has open windows.).

09:24:22: Debug: e:\Projects\wx2.4\src\msw\app.cpp(446): 'UnregisterClass(no
redraw canvas)' failed with error 0x00000584 (class still has open windows.).

================

The code snippet in \Projects\wx2.4\src\msw\control.cpp is below. It
doesn't show much except that CreateWindowEx failed for some reason.
    ...
    m_hWnd = (WXHWND)::CreateWindowEx
                       (
                        exstyle, // extended style
                        classname, // the kind of control to create
                        label, // the window name
                        style, // the window style
                        x, y, w, h, // the window position and size
                        GetHwndOf(GetParent()), // parent
                        (HMENU)GetId(), // child id
                        wxGetInstance(), // app instance
                        NULL // creation parameters
                       );

    if ( !m_hWnd )
    {
        wxLogDebug(wxT("Failed to create a control of class '%s'"), classname);
==> wxFAIL_MSG(_T("something is very wrong"));

        return FALSE;
    }
    ...

Mike Cannon wrote:

Hi,

I'm building a wxPython application that is a wxNotebook with (so far)
40 tabs. Each tab has about 200 controls, mostly wxCheckBox,
wxTextCtrl, and wxStaticText.

At this size, the app fails with the stack trace below. Mostly it
fails in a call to wxCheckBox() (there are more of them) but it will
also fail like this in wxTextCtrl() (example below) or wxStaticText().

[...]

Windows XP, Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32,
wxVERSION_STRING = '2.4.2.4'

[...]

  File "r:\Mello-et-al\FWSPanel.py", line 474, in _ccwx4CheckBoxes
    tb = wxTextCtrl ( pnl, cID, label, tbPos, tbSize )
  File "C:\Python23\lib\site-packages\wxPython\controls.py", line 777, in __init__
    self.this = controlsc.new_wxTextCtrl(*_args,**_kwargs)

wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in e:\Projects\wx2.4\src\msw\control.cpp(134): something is very wrong

[...]

The code snippet in \Projects\wx2.4\src\msw\control.cpp is below. It
doesn't show much except that CreateWindowEx failed for some reason.
    ...
    m_hWnd = (WXHWND)::CreateWindowEx
                       (
                        exstyle, // extended style
                        classname, // the kind of control to create
                        label, // the window name
                        style, // the window style
                        x, y, w, h, // the window position and size
                        GetHwndOf(GetParent()), // parent
                        (HMENU)GetId(), // child id
                        wxGetInstance(), // app instance
                        NULL // creation parameters
                       );

    if ( !m_hWnd )
    {
        wxLogDebug(wxT("Failed to create a control of class '%s'"), classname);
==> wxFAIL_MSG(_T("something is very wrong"));

        return FALSE;
    }

Adding a wxLogLastError call and rebuilding will give you info about the actual failure. I don't know what the actual limits are but the fact that you have over 8000 windows in your app seems to be a likely culprit. Perhaps you could design your app such that the notebook pages are empty when added to the notebook, and then are populated on demand, and unpopulated when the page is no longer visible?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!