[PyKDE] Web article on wxWindows and PyQt

Hans-Peter Jansen hpj at urpla.net
Sun Oct 5 12:23:00 BST 2003

Hi Sundance,

On Sunday 05 October 2003 04:43, Sundance wrote:
> I heard Hans-Peter Jansen said:
> > Conclusion: beware from using qApp.quit(), or even sys.exit(0)
> > without thinking twice. There are almost always better ways to
> > close a PyQt application. Use them.
> This interests me. I've been trying to write a clean exception
> handler around the event loop, so that if an exception occurs in my
> end-user oriented application (darn, I speak like I had a tie...),
> a nice popup will warn the user, and then the app will quit
> cleanly, after saving its conf if at all possible. The quitting
> part is done with qApp.quit(). What should I do instead then?

Just close()ing the main widget should do the job nicely, as long as
the exception doesn't occur in the ctor/dtor paths of the main widget.
This problem only occurs under certain (not to say obscure) 
You should test all exit paths of your app extensively. And remember,
that there are different ways to shut down an app (X closer, ...). 

Needless to say, you cannot protect your app from crashes happened on 
Qt level. Maybe those could be handled within an "envelope process".

Suggestion: modify my test app to your needs and repost. I will do 
some tests, maybe others jump in. At the end, we possibly have some 
skeleton to reuse, which deserves a warm place in PyQt/examples3 in 
order to demonstrate some best practices to handle such requirements.



More information about the PyQt mailing list