Difference between revisions of "Sozi"

From assela Pathirana
Jump to navigationJump to search
Line 3: Line 3:
==Sozi on Steroids==
==Sozi on Steroids==


Due to limitations imposed by Inkscape plugin mechanism (?) registering frames with sozi need to be done one at a time. This makes the user impatient. Following is a script that helps to automate adding a bunch of Sozi frames to a presentation.  See the header for information on usage.  
Due to limitations imposed by Inkscape plugin mechanism (?) registering frames with sozi need to be done one at a time. This makes the user impatient. Following is a script that helps to automate adding a bunch of Sozi frames to a presentation.  See the header for information on usage.
 
<source lang=python>
#!/usr/bin/python
 
#######################################################################
### Assela Pathirana 2012
#######################################################################
### Automates adding number of frames to sozi
### How to:
### 1. Make a frame in inkscape, give it an easy id,  and add it to sozi.
### 2. Make copies of that frame to all other places where needed.
### 3. Run this script with the svg file and that id as arguments. It will
###    add all the copied frames to sozi
### 4. Do the fine tuning of labels with sozi.
######################################################################
import sys
 
if (len(sys.argv) > 2):
rectid=sys.argv[2]
file=sys.argv[1]
else:
print "Usage: $0 <svg file> <\"id\">\n"
        exit(5)
print "Using parent id: ", rectid , "\n"
 
SVG_NAMESPACE = "http://www.w3.org/2000/svg"
SVG= "{%s}" % SVG_NAMESPACE
ns1= "{%s}" % "http://sozi.baierouge.fr"
from lxml import etree
tree=etree.parse(file)
rects=tree.findall("//%srect" % SVG)
sozis=tree.findall("//%sframe" % ns1 )
import re
def choose(x,y):
return re.search(y,x)
parent=filter(lambda x: rectid==x.attrib['id'] , rects)
if  len(parent)!=1 :
print "Can't find the parent id!!"
exit(0)
 
target=filter(lambda x: rectid==x.attrib['%srefid' % ns1 ] , sozis)
if  len(target)!=1 :
print "Can't find the parent in sozi!!"
exit(0)
root=tree.getroot()
myrects=filter(lambda x: re.search(rectid,x.attrib['id'])!=None , rects)
#myrects=list(set(myrects)-set(parent))
myrects=myrects[1:]
# now deepcopy target with attribute changed to id of myrects
from copy import deepcopy
for item in myrects:
print "Doing: " , item.attrib['id']
        newitem=deepcopy(target[0])
        newitem.attrib['%srefid' % ns1]=item.attrib['id']
        root.append(newitem)       
tree.write(file+"_.svg", pretty_print=True)
 
</source>

Revision as of 08:57, 15 December 2021

Sozi] is an Inkscape plugin that makes the vector editing program into a powerful presentation maker. The tool makes non-linear (a bit like Prezi) in SVG format. A main advantage is that the user does not have to have any special software to play them -- A good web browser will do. I have had great success with Firefox and Google Chrome (or Chromium).

Sozi on Steroids

Due to limitations imposed by Inkscape plugin mechanism (?) registering frames with sozi need to be done one at a time. This makes the user impatient. Following is a script that helps to automate adding a bunch of Sozi frames to a presentation. See the header for information on usage.