Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions anim_picker/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down