diff --git a/anim_picker/gui.py b/anim_picker/gui.py index 764a8b5..5eb3689 100644 --- a/anim_picker/gui.py +++ b/anim_picker/gui.py @@ -19,7 +19,7 @@ from handlers import python_handlers from handlers import qt_handlers -from handlers.qt_handlers import QtCore, QtWidgets, QtOpenGL, QtWidgets +from handlers.qt_handlers import QtCore, QtWidgets, QtOpenGL, QtWidgets, QtGui from handlers import __EDIT_MODE__ from handlers import __SELECTION__ @@ -506,11 +506,21 @@ def _get_default_snapshot(self, name='undefined'): def set_background(self, path=None): '''Set character snapshot picture ''' - if not (path and os.path.exists(unicode(path))): + if path: + if os.path.exists(path): + self.background = unicode(path) + else: + # try to find the snapshot pic in the module's images folder as a fallback + newpath = unicode(os.path.join(get_images_folder_path(), os.path.split(path)[1])) + if os.path.exists(newpath): + path = newpath + self.background = unicode(path) + else: + path = self._get_default_snapshot() + self.background = None + else: path = self._get_default_snapshot() self.background = None - else: - self.background = unicode(path) # Load image image = QtGui.QImage(path) @@ -1391,10 +1401,19 @@ def set_background(self, path=None): if not path: return path = unicode(path) - + # Check that path exists - if not (path and os.path.exists(path)): - print '# background image not found: "%s"'%path + # and try to load it from the module's images folder + # if the path doesn't exist + if path: + if not os.path.exists(path): + newpath = unicode(os.path.join(get_images_folder_path(), os.path.split(path)[1])) + if os.path.exists(newpath): + path = newpath + else: + print '# background image not found: "%s"'%path + return + else: return self.background_image_path = path