AUI Child Frame close with

52 views
Skip to first unread message

Zylyco

unread,
May 2, 2018, 8:25:17 AM5/2/18
to wxpytho...@googlegroups.com

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.


What do you think about it ?

Can it be called a bug ?

Or is it caused by my bad code ?


Thanks.


test.py

Robin Dunn

unread,
May 2, 2018, 4:24:18 PM5/2/18
to wxPython-users
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()


--
Robin



Zylyco

unread,
May 3, 2018, 8:20:48 AM5/3/18
to wxpytho...@googlegroups.com

Thank you Robin.

I changed the code to :

    def OnCloseWindow(self, evt):



        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.

zyl...@gmail.com

unread,
May 14, 2018, 12:28:36 PM5/14/18
to wxPython-users

Since I upgraded to wxPython-4.0.2a1.dev3763 :
All is fine now...

Thank you Robin

Reply all
Reply to author
Forward
0 new messages