Close doesn't work?

Hi list,

Something weird is happening in my application (Python 2.3.3, wxPython
2.4.2.4):

If I close the main window (click the cross in the upper right corner) of my
application, the OnExit of the application is not executed, and the
application is not closed. This means that an instance of the application is
still active, but no screens are visible.

Furthermore, if I execute self.Close in the main window, nothing happens.

here is the relevant part of my application:

----------- snip -----------------

class cvs(wxApp):
    def __init__(self, su):
        self.su = su
        wxApp.__init__(self)

    def OnInit(self):

        wxBeginBusyCursor()
        self.SetAppName('Client Volgsysteem')
        self.SetVendorName('Lindix BV. Almere (c) 2003, 2004')
        self.config = Getenv.Config(su=self.su)
        self.p = Opendb.create(self.config)
        self.config.CurrUser = Getuser.CurrUser(self.config)
        self.p.OpenDatabase(self.config)
        BusinessRules.Business_Fldrules()
        self.config.CurrUser.GetUserEnvironment()
        self.p.Filters.InitFilters()
        self.hf=Hoofdframe.create(self.config)
        self.SetTopWindow(self.hf)
        wxEndBusyCursor()
        return True

    def OnExit(self):
        if hasattr(Opendb.TableObjs, 'wp'):
            Opendb.TableObjs.wp.SaveDocuments(Afsluiten=True)
            Opendb.TableObjs.wp.CloseDocuments()
        self.config.CurrUser.UserUpdate()
        self.config.WriteUserConfig()
        self.config.Cached.WriteCache()
        self.config.ExitApplicatie()

if __name__ == '__main__':
    if len(sys.argv) > 1:
        if sys.argv[1] <> '--superuser':
            print "Ongeldige parameter. Alleen --superuser is toegestaan...."
            sys.exit()
        else: su = True
    else: su = False
    os.chdir(os.path.normpath(os.path.dirname(sys.argv[0])))
    cvsapp = cvs(su)
    cvsapp.MainLoop()

----------- snip -----------------

Because the problem occurred after I added an extra "password screen" which is
presented in "self.p.OpenDatabase(self.config)", I thought that the TopWindow
was not defined properly, and so I added self.SetTopWindow.

However, the problem still persists.

Any help would be appreciated

Cheers.
D.Kniep

Oops, Newby error.....

Cheers.
Dick

···

On Saturday 05 June 2004 01:44, Robin Dunn schreef: > Dick Kniep wrote:

[...]

> As you can see When the OK button is pressed the application gets the
> password and Closes itself, so this one should be gone!? Or should I add
> an extra Destroy or something?

Dialogs don't destroy themselves because usually you want to use the
dialog after it has closed to fetch values from it, etc. So yes, you
should call Destroy to get rid of it. Also, you should be calling
EndModal instead of Close for dialogs as it lets you set the value that
will be returned from ShowModal. The typical usage of dialogs is
something like this:

  dlg = PasswordDialog(self)
  rc = dlg.ShowModal()
  if rc == wx.ID_OK:
    self.pw = dlg.Password.GetValue()
  else:
    wx.GetApp().ExitMainLoop()
  dlg.Destroy()