Yes, it looks like it’s a bug in wxWidgets. I’ll poke around later to see if I can find an easy workaround for you or implement a fix.
BTW, it doesn’t avoid this problem, but probably a better way to close all MDI child frames would be a loop like this, since it doesn’t require knowledge of the implementation and hierarchy of the windows:
child = self.GetActiveChild()
while child:
child.Close()
child = self.GetActiveChild()
···
On Wednesday, May 2, 2018 at 5:25:17 AM UTC-7, Zylyco wrote:
Hi all,
I use wxPython 4.0.2a1.dev3717+d4bd2fe, with Python 3.5.3, on a
Linux system.
(The problem doesn't show up on Windows with wxPython 4.0.1 and
Python 3.6.5)
I noticed the message :
wx._core.wxAssertionError: C++ assertion "wxDynamicCast(ptr,
T)" failed at
/tmp/pip-build-5abqkim7/wxPython/ext/wxWidgets/ include/wx/object.h(160)
in wxCheckCast(): wxStaticCast() used incorrectly
Please try the attached code : open 3 ChildFrames for example (or
more), then stay “active” on the last child opened, and use " File
/ Close Parent " :
you should get that message in console.
I tried the same with Python 2.7.13 : same message occurs.
It’s not really an error message, but it’s disturbing.
child = self.GetActiveChild()
while child:
child.Close()
child = self.GetActiveChild()
evt.Skip()
But the result is almost the same :
$ python3 test.py
Traceback (most recent call last):
File “test.py”, line 50, in OnCloseWindow
child.Close()
wx._core.wxAssertionError: C++ assertion
“wxDynamicCast(ptr, T)” failed at
/tmp/pip-build-5abqkim7/wxPython/ext/wxWidgets/include/wx/object.h(160)
in wxCheckCast(): wxStaticCast() used incorrectly
$
I hope you’ll find a way to fix that behavior in next release…
Note :
I obtained that my real project code can works, but that alert
message (still present) caused I had to struggled with it for a
while, ignoring if this alert was belonging to … my python’s
code or a bug ? Now my mind is clear.
···
Le 02/05/2018 à 22:24, Robin Dunn a
écrit :
Yes, it looks like it's a bug in wxWidgets. I'll poke
around later to see if I can find an easy workaround for you
or implement a fix.
BTW, it doesn't avoid this problem, but probably a better
way to close all MDI child frames would be a loop like this,
since it doesn’t require knowledge of the implementation and
hierarchy of the windows: