简体   繁体   中英

Sub frame does not destroy in python

I have a program that I'm trying to develop but I guess I don't know the proper way to make subframes. I've looked at several examples and can't seem to get it to destroy the frame when it's closed. I get the following error readout (using pycharm):

Exception wx._core.PyDeadObjectError: PyDeadObjectError('The C++ part of the
Choice object has been deleted, attribute access no longer allowed.',) in
<bound method pvFileINdialog.__del__ of <fileIO.pvFileIOGUIFileIOdialog.pvFileINdialog;
proxy of <Swig Object of type 'wxDialog *' at 0x340cc70> >> ignored

Although the interpreter takes care of the problem, I would like to learn the proper way to take care of it.

If I move the destroy and close commands around no combination changes the result.

The code of interest is:

#in MainFrame.py:

def fileimport(self, event):

    importprompt = pvFileIOGUIFileIOdialog.pvFileINdialog(self)

    importprompt.ShowModal()

    importprompt.Destroy()

#referring to pvFileIOGUIFileIOdialog.pvFileINdialog :

class pvFileINdialog(pvFileIOGUI.FileINdialog):
    def __init__(self, child):
        pvFileIOGUI.FileINdialog.__init__(self, child)

#which refers to pvFileIOGUI.FileINdialog :

class FileINdialog(wx.Dialog):
    def __init__(self, child):
        wx.Dialog.__init__(self, child, id=wx.ID_ANY, title=u"Select Import Method...",     pos=wx.DefaultPosition,
                           size=wx.Size(800, 600), style=wx.DEFAULT_DIALOG_STYLE)


#and is closed by this routine in pvFileIOGUIFileIOdialog.py:

    def cancelclk(self, event):
        self.Close()
        return 0

It's difficult to understand what goes on because your error message refers to a Choice , but your code doesn't show any choices at all, so something is probably missing, ie the problem is probably in the part which you don't show. But in any case, calling Destroy() is not necessary and you shouldn't do it unless you have some real reason (do you?). So I'd start by removing all calls to Destroy() from your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM