The code is worth a thousand words, so here are my thousand words:try:import wx_ # Intentionally added the trailing underscore to invoke ImportErrorexcept ImportError:print("You don't seem to have wxPython installed.")
class MyFrame(wx.Frame):passI have a problem that even though the ImportError exception is properly handled the propagation does not stop there but propagates to class MyFrame(wx.Frame) and then throws the NameError exception at me, saying "Name 'wx' is not defined.". It doesn't print the "You don't seem to have wxPython installed." message at all.How can I fix my code so that if an ImportError is caught the propagation to class MyFrame(wx.Frame) does not happen?
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I forgot to mention that I create a message box in which I tell the user that he/she doesn't have wxPython installed and inform the user to install it. This message box is in the except block.
ctypes.windll.user32.MessageBoxA is the thing I use as the message box. But that message box is never shown. I immediately get the NameError exception that "name 'wx' is not defined" because Python goes and sees the line class MyFrame(wx.Frame) and throws me that NameError. So how can I make this work? I wanna show that message box. Any ideas?
Thanks. I'll try the code when I come back from work.
Don't bother, I used constants to make the calling function more descriptive. ;)