wxPython中的AuiMDI帧问题

wxPython中的AuiMDI帧问题,wxpython,wxwidgets,mdichild,Wxpython,Wxwidgets,Mdichild,我正在创建一个AuiMDIParent框架,在父框架内我有一个AuiMDIChild框架。在子框架内,我有一个显示图像的面板。我的问题是,当我运行我的代码(如下所示)时,我得到了期望的结果,但是当我试图关闭作为父帧的主窗口时,什么也没有发生。然后,当我关闭子帧时,整个应用程序将关闭,包括父帧(不仅仅是子帧) 我不知道为什么会这样。请帮我弄清楚是否有人遇到过这样的问题。如果你运行我的代码,你会对这个问题有更好的了解 谢谢 import wx import wx.aui class ParentF

我正在创建一个AuiMDIParent框架,在父框架内我有一个AuiMDIChild框架。在子框架内,我有一个显示图像的面板。我的问题是,当我运行我的代码(如下所示)时,我得到了期望的结果,但是当我试图关闭作为父帧的主窗口时,什么也没有发生。然后,当我关闭子帧时,整个应用程序将关闭,包括父帧(不仅仅是子帧)

我不知道为什么会这样。请帮我弄清楚是否有人遇到过这样的问题。如果你运行我的代码,你会对这个问题有更好的了解

谢谢

import wx
import wx.aui

class ParentFrame(wx.aui.AuiMDIParentFrame):
    '''
        This is main frame
    '''

    def __init__(self,parent,id,title):
        '''
            Creates a Parent Frame which has child frames into it.
        '''
        wx.aui.AuiMDIParentFrame.__init__(self,parent,id,title,
                                          size=(900,700),
                                          style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
        self.SetMinSize((500,500))
        self.CreateStatusBar()

class NetworkVisualizationFrame(wx.aui.AuiMDIChildFrame):
    '''
        This is a child frame
    '''

    def __init__(self,parent=None,id=-1,title="Network Visualization",image="Default.png"):
        '''
            Creates a child frame inside parent frame.
        '''
        wx.aui.AuiMDIChildFrame.__init__(self,parent,id,title)
        (frameWidth,frameHeight) = self.GetSizeTuple()

        #=========================================================
        # Create an image panel
        #=========================================================
        imagePanelHeight = int(frameHeight)
        imagePanelWidth = int(0.7 * frameWidth)
        self.imagePanel = wx.Panel(self,id=-1,name="Image Panel",
                                   style=wx.BORDER_THEME,
                                   size=(imagePanelWidth,imagePanelHeight))
                    self.loadImage(image)

        self.Bind(wx.EVT_SIZE, self.onResize)
        self.Bind(wx.EVT_PAINT, self.onPaint)

    def loadImage(self,image):
        #==================================================
        # Find the aspect ratio of the image
        #==================================================
        self.png = wx.Image(image, wx.BITMAP_TYPE_PNG)
        imageHeight = self.png.GetHeight()
        imageWidth = self.png.GetWidth()
        self.aspectRatio = imageWidth/imageHeight
        self.bitmap = wx.BitmapFromImage(self.png)

    def onResize(self,event):
        (frameWidth,frameHeight) = self.GetSizeTuple()
        imagePanelWidth = int(0.7 * frameWidth)
        imagePanelHeight = int(frameHeight) 
        self.imagePanel.SetSize((imagePanelWidth,imagePanelHeight))
        (w, h) = self.getBestSize()
        self.imagePanel.SetSize((w,h)) 
        self.scaledPNG = self.png.Scale(w, h)
        self.bitmap = wx.BitmapFromImage(self.scaledPNG)
        self.Refresh()

    def onPaint(self,event):
        dc = wx.PaintDC(self.imagePanel)
        dc.DrawBitmap(self.bitmap, 0, 0, useMask=False)

    def getBestSize(self):
        (w,h) = self.imagePanel.GetSizeTuple()
        # Keep the height same and change width of the image according to aspect ratio
        newWidth = int (self.aspectRatio * h)
        newSize = (newWidth,h)
        return newSize

app = wx.PySimpleApp()
parentFrame = ParentFrame(None,-1,"Main Frame")
NetworkVisualizationFrame(parentFrame,-1,"Network Visualization","Artifacts_vs_Elaborations_36855.png")
parentFrame.Show()
app.MainLoop()

这可能是因为子帧的父级为“None”,而不是mdi父帧