Skip to content

Child windows are not destroyed when the parent is destroyed #630

@AndersMunch

Description

@AndersMunch

Operating system: Windows 10.
wxPython version: 4.0.0b2
Stock or custom build: No.
Python version: 2.7.14
Stock or custom build: No.

Description of the problem:
Child windows are automatically deleted when the parent is deleted, according to http://docs.wxwidgets.org/stable/overview_windowdeletion.html. But that doesn't seem to apply to destroying frames in wxPython.

Run this, and close the parent window, then the parent's Destroy runs, but the child's doesn't.

import wx
class ChildFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1)
        wx.StaticText(self, -1, "child")
    def Destroy(self):
        print("Child Destroy")
        return wx.Frame.Destroy(self)
class ParentFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1)
        wx.StaticText(self, -1, "parent")
        ChildFrame(self).Show()
    def Destroy(self):
        print("Parent Destroy")
        return wx.Frame.Destroy(self)
app = wx.App()
fr = ParentFrame(None)
fr.Show(True)
app.MainLoop()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions