Document Frame won't close!

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()

Please if anyone has any advice, I’d love to hear it. The code I provided should run if pasted into a .py file. After New… and a new frame is created, why won’t it close? TIA

···

Send e-mail anywhere. No map, no compass. Get your Hotmail® account now.

Josh Petitt wrote:

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

I don't know the docview code very well so this is just a guess, but one difference I see between your code and the sample is that your view's OnCreate is not returning True. Does that make any difference?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin,

Your a genius! That appears to be it. Thank you!

···

----- Original Message ----- From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.wxwidgets.org>
Sent: Sunday, December 21, 2008 1:16 PM
Subject: Re: [wxpython-users] Document Frame won't close!

Josh Petitt wrote:

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

I don't know the docview code very well so this is just a guess, but one difference I see between your code and the sample is that your view's OnCreate is not returning True. Does that make any difference?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users