[wxPython-dev] wx.Controls without parents

Chris Mellon arkanes at gmail.com
Thu Jul 19 10:33:01 PDT 2007


On 7/19/07, Frank Tobia <frank.tobia at gmail.com> wrote:
> Hi all,
>
> I've run into a cross-platform inconsistency involving Controls and their
> need for parents.  I want to clarify that this behavior is expected, so I
> can update the unit test suite accordingly.
>
> Running the following at an interactive prompt:
>
> import wx
> app = wx.PySimpleApp()
> b = wx.Button(None)
>
> does different things depending on your platform.  Apparently, wxGtk will
> instantiate a parentless Button with no problems.  On Windows, we get
>
> >>> b = wx.Button(None)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py",
> line
> 86, in __init__
>
> _controls_.Button_swiginit(self,_controls_.new_Button(*args,
> **kwargs))
> wx._core.PyAssertionError: C++ assertion "parent" failed at
> ..\..\src\common\ctr
> lcmn.cpp(79) in wxControlBase::CreateControl(): all controls must have
> parents
>
> and the same type of thing on Mac (see the results at the bottom of
> http://wiki.wxpython.org/Test_Suite_Results?action=show).
> Example:
>
>
>  testAllControlsNeedParents (testRadioBox.RadioBoxTest) Traceback (most
> recent call last):
>  File
> "/Users/cody/Desktop/Python/wx_stuff/unittest/unittest/testControl.py",
> line 31, in testAllControlsNeedParents
>
>  class_under_test(None)
>  File
> "//Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-unicode
> /wx/_controls.py", line 2356, in __init__
> _controls_.RadioBox_swiginit(self,_controls_.new_RadioBox(*args,
> **kwargs))
> PyAssertionError: C++ assertion "parent" failed at /BUILD/wxPython-
> src-2.8.4.0/src/mac/carbon/window.cpp(1090) in Create():
> can't create wxWindowMac without parent
>
>
> Additionally, trying to instantiate other wx.Windows without parents will
> also fail on Windows and Mac but not Gtk.  Can anyone clarify what causes
> these discrepancies, and whether or not they are the correct behavior?
> Thanks.
>

I assume that the wxGtk implementation doesn't perform the assert and
that Gtk does magical parent escalation even for controls similar to
what Qt does (you can show any control in Qt without a parent and it
will magically get a frame).

This isn't supported under wxWidgets though and I'd consider it a
(nominal) bug that it works on wxGtk. I know I've certainly written
code that assumes that any control must have a parent.




More information about the wxpython-dev mailing list