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 120039
In Process

The Archive Base Latest Questions

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

I’m coding the menu for an application I’m writing in python, using wxPython libraries

  • 0

I’m coding the menu for an application I’m writing in python, using wxPython libraries for the user interface, and I’m attempting to add icons to some of the menu items. Because I’m trying to be conscientious about it, I’m trying to limit the damage done if one of the image files referenced doesn’t exist, and the most simple method (in my mind) is to use exceptions.

The trouble is, when I link to a file that doesn’t exist, an exception isn’t thrown. Instead I get a horrific message box stating:

Can't load image from <path>: Image does not exist.

This message is exactly the type of thing I’m trying to stop, but even with the broadest exception catching statement nothing works.

This is a cut down version, taking what seems to be relevant, from what I’ve written:

NewProject = wx.MenuItem(File, -1, '&New Project\tCtrl+N', 'Create a new project') try:     # raises an error message but not an exception     NewProject.SetBitmap(wx.Image( <path>  ), wx.BITMAP_TYPE_PNG).ConvertToBitmap()) except Exception:     pass 

So these are my questions: What am I doing wrong? Am I approaching this in the wrong direction, putting too much emphasis on exceptions, when there are other ways around it (though non that seem in my head to be as simple)? Is this a bug in the wxPython library, since I’m pretty sure it should be throwing an exception even if it’s not the best way around it?

p.s. The best a Google search could do was recommend I converted all the images to python code using the img2py module that comes with wxPython, but I would prefer to keep the images in image format for what I’m doing.

  • 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:44:53+00:00Added an answer on May 11, 2026 at 3:44 am

    That is a known issue. Robin Dunn answered it a couple of times: just create your Logging method eg.:

    dummy_log=wx.LogNull() 

    when the variable dummy_log runs out of scope, normal logging is enabled again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 102k
  • Answers 102k
  • 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 could use a PHP function to do that. Quickly,… May 11, 2026 at 8:14 pm
  • Editorial Team
    Editorial Team added an answer You could simply strip user1 out of the URL: RewriteCond… May 11, 2026 at 8:14 pm
  • Editorial Team
    Editorial Team added an answer You can (and maybe should) also use the free command… May 11, 2026 at 8:14 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

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.