[Python] Sub frame does not destroy

timer Asked: Oct 24th, 2013

Question Description

I’m studying for my Programming class and don’t understand how to answer this. Can you help me study?

I have a program 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 work 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

All though the interpreter takes care of the problem i would like to learn the propper way to take care of it. Here is a zip of the entire program so far.  When you run it and click "file/Import data" the subframe opens, and then when you hit the "cancel" button or the "x" button it closes but reports the error.

If moved the destroy and close commands around and nothing changes the result

The code of interest is:

#in MainFrame.py:   def fileimport(self, event):

        importprompt = pvFileIOGUIFileIOdialog.pvFileINdialog(self)


        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

Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors