Fixed save and open images
This commit is contained in:
parent
5143fe7d45
commit
58b3abe5dd
|
|
@ -504,6 +504,10 @@ def open_file(widget=None):
|
||||||
thetarfile.extractall(path=svlgui.SECURETEMPDIR)
|
thetarfile.extractall(path=svlgui.SECURETEMPDIR)
|
||||||
for i in svlgui.Library:
|
for i in svlgui.Library:
|
||||||
if i.type=="Image":
|
if i.type=="Image":
|
||||||
|
if not hasattr(i,'path'):
|
||||||
|
i.val = svlgui.SECURETEMPDIR+"/"+i.val.split(os.sep)[-1]
|
||||||
|
i.set_image(i.val)
|
||||||
|
else:
|
||||||
i.path = svlgui.SECURETEMPDIR+"/"+i.path.split(os.sep)[-1]
|
i.path = svlgui.SECURETEMPDIR+"/"+i.path.split(os.sep)[-1]
|
||||||
i.set_image(i.path)
|
i.set_image(i.path)
|
||||||
if not hasattr(i, 'iname'):
|
if not hasattr(i, 'iname'):
|
||||||
|
|
@ -529,6 +533,18 @@ def save_file(widget=None):
|
||||||
lastpath = os.path.abspath(".")
|
lastpath = os.path.abspath(".")
|
||||||
for i in svlgui.Library:
|
for i in svlgui.Library:
|
||||||
if i.type=="Image":
|
if i.type=="Image":
|
||||||
|
if not hasattr(i, 'path'):
|
||||||
|
try:
|
||||||
|
os.chdir(os.sep.join(i.val.split(os.sep)[:-1]) or i.origpath)
|
||||||
|
i.val = i.val.split(os.sep)[-1]
|
||||||
|
thetarfile.add(i.val.split(os.sep)[-1])
|
||||||
|
except OSError:
|
||||||
|
tmpdir = tempfile.mkdtemp()
|
||||||
|
os.chdir(tmpdir)
|
||||||
|
i.pilimage.save(i.val)
|
||||||
|
thetarfile.add(i.val)
|
||||||
|
os.remove(i.val)
|
||||||
|
else:
|
||||||
print "i.path: ",i.path
|
print "i.path: ",i.path
|
||||||
try:
|
try:
|
||||||
os.chdir(os.sep.join(i.path.split(os.sep)[:-1]) or i.origpath)
|
os.chdir(os.sep.join(i.path.split(os.sep)[:-1]) or i.origpath)
|
||||||
|
|
@ -575,6 +591,10 @@ def import_to_stage(widget=None):
|
||||||
for i in ("jpg","png","bmp"):
|
for i in ("jpg","png","bmp"):
|
||||||
if thefile.endswith(i):
|
if thefile.endswith(i):
|
||||||
# im = svlgui.Image(thefile)
|
# im = svlgui.Image(thefile)
|
||||||
|
if svlgui.PLATFORM=="osx":
|
||||||
|
# sips is OSX's built-in image manipulation tool
|
||||||
|
os.system("sips -s format png "+thefile+" --out "+svlgui.SECURETEMPDIR+"/"+thefile.split("/")[-1])
|
||||||
|
thefile = svlgui.SECURETEMPDIR+"/"+thefile.split("/")[-1]
|
||||||
im = box(100,100,200,200,svlgui.Color(thefile))
|
im = box(100,100,200,200,svlgui.Color(thefile))
|
||||||
print im.filled
|
print im.filled
|
||||||
im.onMouseDown = onMouseDownObj
|
im.onMouseDown = onMouseDownObj
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,11 @@ Library = []
|
||||||
|
|
||||||
|
|
||||||
class Color (object):
|
class Color (object):
|
||||||
|
def __getstate__(self):
|
||||||
|
dict = self.__dict__.copy()
|
||||||
|
print dict
|
||||||
|
dict['image'] = None
|
||||||
|
return dict
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
if type(val)==type([]):
|
if type(val)==type([]):
|
||||||
self.type = "RGB"
|
self.type = "RGB"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue