dabo Commit
Revision 6196
Date: 2010-11-21 07:45:21 -0800 (Sun, 21 Nov 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6196

Changed:
U   trunk/dabo/ui/uiwx/dImage.py

Log:
Modified the behavior when setting the Picture property. Instead of raising an 
error when set to a non-existent file, it will write to the error log and 
return.

Changed the names of the getter/setter methods for Picture to be more 
consistent with the rest of the framework.


Diff:
Modified: trunk/dabo/ui/uiwx/dImage.py
===================================================================
--- trunk/dabo/ui/uiwx/dImage.py        2010-11-18 18:44:04 UTC (rev 6195)
+++ trunk/dabo/ui/uiwx/dImage.py        2010-11-21 15:45:21 UTC (rev 6196)
@@ -188,10 +188,10 @@
                return cnt
 
 
-       def _getPic(self):
+       def _getPicture(self):
                return self._picture
 
-       def _setPic(self, val):
+       def _setPicture(self, val):
                if isinstance(val, wx.Image):
                        # An image stored as a stream is being used
                        self.__image = self.__val = val
@@ -216,10 +216,14 @@
                                val = dabo.ui.getImagePath(val)
                                if val is None or not os.path.exists(val):
                                        # This will raise an IOError if it fails
-                                       val = 
utils.resolvePathAndUpdate(origVal)
+                                       try:
+                                               val = 
utils.resolvePathAndUpdate(origVal)
+                                       except IOError:
+                                               val = None
                                if val is None or not os.path.exists(val):
                                        # Bad image reference
-                                       raise IOError("No file named '%s' 
exists." % origVal)
+                                       dabo.log.error(_("No file named '%s' 
exists.") % origVal)
+                                       return
                        self._picture = val
                        self._rotation = 0
                        idx = self.PictureIndex
@@ -293,9 +297,9 @@
                                except TypeError:
                                        # No dice, so just bail
                                        img = wx.EmptyImage(1, 1)
-                               self._setPic(img)
+                               self._setPicture(img)
                        else:
-                               self._setPic(val)
+                               self._setPicture(val)
                        if ((type(self.__imageData) != type(val)) or 
(self.__imageData != val)):
                                tfname = self.Application.getTempFile(ext="")
                                try:
@@ -321,7 +325,7 @@
        FrameCount = property(_getFrameCount, None, None,
                        _("Number of frames in the current image. Will be 1 for 
most images, but can be greater for animated GIFs, ICOs and some TIFF files. 
(read-only) (int)"))
 
-       Picture = property(_getPic, _setPic, None,
+       Picture = property(_getPicture, _setPicture, None,
                        _("The file used as the source for the displayed image. 
 (str)") )
 
        PictureIndex = property(_getPictureIndex, _setPictureIndex, None,



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to