I am having the hardest time getting a document frame to close with wx.docview. I’ve posted my code below (very simple) and stripped out all the unnessary. This is basically cut and pasted directly from the samples. Do I somehow have to catch and process an event? With docview and DocApp setting everything else up (menus, toolbars, etc.), I assumed that it would also set up something as simple as closing a child frame. BTW, I am running in MDI mode and the child frame is a wx.lib.docview.DocMDIChildFrame. Any assistance/insight would be greatly appreciated. TIA
#import wxWidgets
import wx
import wx.lib.docview as docview
import wx.lib.pydocview as pydocview
_ = wx.GetTranslation
class Application(pydocview.DocApp):
“”“Main application”""
def __init__(self, redirect=False, filename=None):
"""Initialize application"""
pydocview.DocApp.__init__(self, redirect, filename)
def OnInit(self):
"""Do wx initialization, create main application frame"""
pydocview.DocApp.OnInit(self)
# set up document/view framework
docManager = docview.DocManager(flags = self.GetDefaultDocManagerFlags())
self.SetDocumentManager(docManager)
# Create a template for text documents and associate it with the docmanager
netTemplate = docview.DocTemplate(docManager,
_("Network"),
"*.net",
_("Network"),
_("net"),
_("Network Document"),
_("Network View"),
NetworkDocument,
NetworkTreeView,
icon=wx.Icon("rc\\icon_network.bmp", wx.BITMAP_TYPE_ANY))
docManager.AssociateTemplate(netTemplate)
If it is an MDI app open the main frame
self.OpenMainFrame()
return True
class NetworkTreeView(docview.View):
“”“Network View”""
def __init__(self):
docview.View.__init__(self)
def OnCreate(self, doc, flags):
"""Create view"""
frame = wx.GetApp().CreateDocumentFrame(self, doc, flags, title="Network Browser")
self.SetFrame(frame)
class NetworkDocument(docview.Document):
“”“Network Document”""
def __init__(self):
super(NetworkDocument, self).__init__(self)
···
#-------------------------------------------------------------------------------
def main():
“”“main entry point”""
app = Application(redirect=False)
app.MainLoop()
if name == “main”:
main()