[wxPython] OnExit() and wxGetApp()

Hi all

First, I'd just like to thank everyone who's done any work on wxPython. I'm
starting to get the hang of it and I think it's really great.

I've got two little problems though. It looks like wxApp.OnExit() doesn't get
executed when the app exits. I'm not sure if I'm closing it the correct way
though. I just call self.Close(true) in the app's TopWindow.

I would also like to use wxGetApp(). Before calling wxGetApp one should
call DECLARE_APP(). It doesn't look like either of these are implemented in
wxpython though. Being new to python, could someone maybe tell me how to
create a truly global variable that is accessible from all other modules and
classes?

Thanks

···

--
------------------
Sarel Botha
sjbotha@email.com
------------------

99 little bugs in the code, 99 bugs in the code,
          fix one bug, compile it again...
          101 little bugs in the code....

I've got two little problems though. It looks like wxApp.OnExit() doesn't

get

executed when the app exits.

I havn't yet virtualized all of wxApp's methods to look for the existence of
Python methods and invoke them. If it's important I can add them, but I've
never had the need myself so figured I'd save the overhead.

I'm not sure if I'm closing it the correct way
though. I just call self.Close(true) in the app's TopWindow.

This is correct. When all top level windows have closed then the MainLoop
will exit.

I would also like to use wxGetApp(). Before calling wxGetApp one should
call DECLARE_APP(). It doesn't look like either of these are implemented

in

wxpython though.

wxGetApp can be done, but it will ahve the same trouble that some other
fucntions have: It won't return your python object but a new shadow around
the C++ object. DECALRE_APP is not needed as it is just an ugly macro
needed by C++ so it can dream about being an easy language.

Being new to python, could someone maybe tell me how to
create a truly global variable that is accessible from all other modules

and

classes?

in main.py:

# (some wxApp derived class and etc. not shown)

app = MyApp(0)
app.MainLoop()

in othermodule.py

import main
print main.app.GetAppName()

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!