Example #1
0
def save_file(widget=None):
	data = pickle.dumps((root,svlgui.Library))
	tarinfo = tarfile.TarInfo('basefile')
	tarinfo.size = len(data)
	if svlgui.FILE.name.startswith(svlgui.TEMPDIR):
		thetarfile = tarfile.open(fileobj=svlgui.file_dialog("save").open('wb'),mode="w:gz")
		print thetarfile.name
	else:
		thetarfile = tarfile.open(svlgui.FILE.name,mode="w:gz")
	thetarfile.addfile(tarinfo, StringIO.StringIO(data))
	#Save the path so we can come back here
	lastpath = os.path.abspath(".")
	for i in svlgui.Library:
		if i.type=="Image":
			print "i.path: ",i.path
			try:
				os.chdir(os.sep.join(i.path.split(os.sep)[:-1]) or i.origpath)
				i.path = i.path.split(os.sep)[-1]
				thetarfile.add(i.path.split(os.sep)[-1])
			except OSError:
				tmpdir = tempfile.mkdtemp()
				os.chdir(tmpdir)
				i.pilimage.save(i.path)
				thetarfile.add(i.path)
				os.remove(i.path)
			os.chdir(lastpath)
	thetarfile.close()
	svlgui.FILE = thetarfile
Example #2
0
def import_to_stage(widget=None):
	thefile = svlgui.file_dialog("open",None,["jpg","png","bmp"]).path
	im = svlgui.Image(thefile)
	im.onMouseDown = onMouseDownObj
	im.onMouseMove = onMouseMoveObj
	im.onMouseDrag = onMouseDragObj
	im.onMouseUp = onMouseUpObj
	im.onKeyDown = onKeyDownObj
	root.descendItem().add(im)
	MainWindow.stage.draw()
Example #3
0
def open_file(widget=None):
	global root
	MainWindow.stage.delete(root)
	shutil.rmtree(svlgui.SECURETEMPDIR)
	thetarfile = tarfile.open(fileobj=svlgui.file_dialog("open").open("rb"),mode="r:gz")
	basefile = thetarfile.extractfile("basefile")
	root, svlgui.Library = pickle.load(basefile)
	svlgui.SECURETEMPDIR = tempfile.mkdtemp()
	thetarfile.extractall(path=svlgui.SECURETEMPDIR)
	for i in svlgui.Library:
		if i.type=="Image":
			i.path = svlgui.SECURETEMPDIR+"/"+i.path.split(os.sep)[-1]
			i.set_image(i.path)
			if not hasattr(i, 'iname'):
				i.iname = None
	MainWindow.stage.add(root, 0, 0)
	MainWindow.stage.draw()
	MainWindow.timelinebox.root = root
	MainWindow.timelinebox.draw()
	thetarfile.close()