In Win XP (SP2, Python 2.5.2, wxPython 2.8.? - latest version)
If try this:
try:
window.SetIcon(‘path/to/icon.ico’)
finally:
pass
AND the icon does not exist, I get a pop up window
Python Error
Failed to load icon from file ‘path/to/icon.ico’ (error 2: the system ca not find the file specified)
No exceptions are raised (e.g. the try/execpt does not catch it).
Am I doing something wrong? This does not seem very pythonic.
I just ditched the try/catch and used os.path.exists() to see if the file exists.
I looked at the wx.Python docs (new and old) and wx.Widgets docs, but could not really find any detailed information. I also looked things up in wxPython in Action, to no avail.
So, where do people in the know really find details about wx.Python programming? I find myself digging though the wx Demo code and hoping there is something there that is close what I’m trying to do. If not, I try google and code searches. If I can’t find an example, the docs never seem to help me. I must be missing somthing.
Ok, I understand that: I should use except, not finally (in fact, I
think I did that at first). However, even if I add the except, I
don't think it will mater -- I'm see no execptions thrown -- I'll try
later to verify this.
···
On Tue, Jun 3, 2008 at 1:25 PM, Mike Driscoll <mike@pythonlibrary.org> wrote:
Kevin Grover wrote:
In Win XP (SP2, Python 2.5.2, wxPython 2.8.? - latest version)
If try this:
try:
window.SetIcon('path/to/icon.ico')
finally:
pass
AND the icon does not exist, I get a pop up window
Python Error
Failed to load icon from file 'path/to/icon.ico' (error 2: the system ca not find the file specified)
No exceptions are raised (e.g. the try/execpt does not catch it).
Am I doing something wrong? This does not seem very pythonic.
I just ditched the try/catch and used os.path.exists() to see if the file exists.
I looked at the wx.Python docs (new and old) and wx.Widgets docs, but could not really find any detailed information. I also looked things up in wxPython in Action, to no avail.
So, where do people in the _know_ really find details about wx.Python programming? I find myself digging though the wx Demo code and hoping there is something there that is close what I'm trying to do. If not, I try google and code searches. If I can't find an example, the docs never seem to help me. I must be missing somthing.
I think you want to use a try/except, NOT a try/finally. The try/finally won't catch the exception, it will only make sure that pass is called, so-to-speak. See also:
http://docs.python.org/ref/try.html
http://www.diveintopython.org/file_handling/index.html
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users