Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 117465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:20:26+00:00 2026-05-11T03:20:26+00:00

I have a wxPython application that relies on an external config file. I want

  • 0

I have a wxPython application that relies on an external config file. I want provide friendly message dialogs that show up if there are any config errors. I’ve tried to make this work by wrapping my app.MainLoop() call in a try/except statement.

The code below works for the init code in my MainWindow frame class, but doesn’t catch any exceptions that occur within the MainLoop. How can I catch these exceptions as well?

if __name__ == '__main__':     app = MyApp(0)     try:         MainWindow(None, -1, 'My Cool App')         app.MainLoop()     except ConfigParser.Error, error_message:         messagebox = wx.MessageDialog(None, error_message, 'Configuration Error', wx.OK | wx.ICON_ERROR)         messagebox.ShowModal() 

I’ve read some mention of an OnExceptionInMainLoop method that can be overridden in the wx.App class, but the source I read must be out of date (2004) since wx.App no longer seems to have a method by that name.

EDIT:

I need to be able to catch unhandled exceptions during my mainloop so that I can further handle them and display them in error dialogs, not pass silently, and not terminate the app.

The sys.excepthook solution is too low level and doesn’t play nice with the wxPython mainloop thread. While the link to the other answer does the same try/except wrapping around the mainloop which doesn’t work due, once again, to wxPython spawning a different thread for the app/ui.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:20:27+00:00Added an answer on May 11, 2026 at 3:20 am

    I coded something like this for Chandler, where any unhandled exceptions pop up a window with the stack and other info, and users can put in additional comments (what did they do when it happened etc.) and submit it for Chandler developers. A bit like the Mozilla Talkback (nowadays they use Breakpad I believe) feature if you will.

    To do this in wxPython, you need to provide redirect parameter to wx.App. This will pop up wx.PyOnDemandOutputWindow (you will probably want to override it to provide a nicer looking implementation).

    The relevant source files in Chandler are here:

    • Chandler.py starts the application and sets the redirect attribute, as well as tries to catch and display error dialogs in case normal application startup fails
    • Application.py customizes the application object, including setting up our customized wx.PyOnDemandOutputWindow
    • feedback.py has the implementation for the customized wx.PyOnDemandOutputWindow; it will additionally need feedback.xrc and feedback_xrc.py
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 134k
  • Answers 134k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can do this with the standard Calendar Control and… May 12, 2026 at 6:44 am
  • Editorial Team
    Editorial Team added an answer document.getElementsByTagName('body')[0].innerHTML will return a string of everything in the body… May 12, 2026 at 6:44 am
  • Editorial Team
    Editorial Team added an answer You can set the HeaderCell SortGlyphDirection to Ascending, and then… May 12, 2026 at 6:44 am

Related Questions

I have a wxPython application that sends multipart emails with HTML and embedded images.
I have a wxPython application and I'm using Evince to display the reports it
I'm starting out with wxPython and have been working my way through every tutorial
I've written a setup.py script for py2exe, generated an executable for my python GUI

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.