Issue 69: Can't load other SVG files -
Status:  Fixed
Owner:
Closed:  Jun 2009
Reported by neho...@gmail.com, May 27, 2009
What steps will reproduce the problem?
1. downloaded -
http://svn.sourceforge.net/viewvc/*checkout*/inkscape/inkscape/trunk/share/examples/car.svg


2. Modified svg.py in examples to load the image

# -*- coding: utf-8 -*-
from pymt import *

# PYMT Plugin integration
IS_PYMT_PLUGIN = True
PLUGIN_TITLE = 'SVG Viewer'
PLUGIN_AUTHOR = 'Nathanaël Lécaudé'
PLUGIN_DESCRIPTION = 'This is an example of Scalable Vector Graphics using
the $


def pymt_plugin_activate(w, ctx):
    sun = MTScatterSvg(filename = '../svg/sun.svg', pos = (200,200))
    cloud = MTScatterSvg(filename = '../svg/cloud.svg', pos = (50,100))
    ship = MTScatterSvg(filename = '../svg/ship.svg', pos = (280,100))
    car = MTScatterSvg(filename = '../svg/car.svg', pos = (380,300))
    ctx.c = MTKinetic()
    ctx.c.add_widget(sun)
    ctx.c.add_widget(cloud)
    ctx.c.add_widget(ship)
    ctx.c.add_widget(car)
    w.add_widget(ctx.c)

def pymt_plugin_deactivate(w, ctx):
    w.remove_widget(ctx.c)

if __name__ == '__main__':
    w = MTWindow()
    ctx = MTContext()
    pymt_plugin_activate(w, ctx)
    runTouchApp()
    pymt_plugin_deactivate(w, ctx)



3. Getting error codes
nehock@nehock-desktop:~/pymt-0.2/examples$ cd
/home/nehock/pymt-0.2/examples/svg
nehock@nehock-desktop:~/pymt-0.2/examples/svg$ python svg.py
Xlib:  extension "Generic Event Extension" missing on display ":1011.0".
Xlib:  extension "Generic Event Extension" missing on display ":1011.0".
[INFO   ] Fbo will use software Framebuffer                             
Xlib:  extension "Generic Event Extension" missing on display ":1011.0".
Xlib:  extension "Generic Event Extension" missing on display ":1011.0".
Xlib:  extension "Generic Event Extension" missing on display ":1011.0".
Xlib:  extension "Generic Event Extension" missing on display ":1011.0".
Xlib:  extension "Generic Event Extension" missing on display ":1011.0".
[DEBUG  ] loading ../svg/sun.svg                                        
[DEBUG  ] loading ../svg/cloud.svg                                      
[DEBUG  ] loading ../svg/ship.svg                                       
[DEBUG  ] loading ../svg/car.svg                                        
[ERROR  ] incorrect length for colour black                             
None                                                                    
[ERROR  ] exception parsing color black                                 
Traceback (most recent call last):                                      
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
85, in parse_color
    return [r,g,b,255]                                                    
                  
UnboundLocalError: local variable 'r' referenced before assignment        
                  
[ERROR  ] exception while parsing element <Element
'{http://www.w3.org/2000/svg}linearGradient' at 0xb9e30e0>
Traceback (most recent call last):                                        
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
561, in parse_element             
    self.parse_element(c)                                                 
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
556, in parse_element             
    self.gradients[e.get('id')] = LinearGradient(e, self)                 
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
164, in __init__                  
    color[3] = int(float(e.get('stop-opacity', '1')) * 255)               
                                  
TypeError: 'NoneType' object does not support item assignment             
                                  
[ERROR  ] exception while parsing element <Element
'{http://www.w3.org/2000/svg}defs' at 0xb9e30c8>          
Traceback (most recent call last):                                        
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
403, in parse_doc                 
    self.parse_element(e)                                                 
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
561, in parse_element             
    self.parse_element(c)                                                 
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
556, in parse_element             
    self.gradients[e.get('id')] = LinearGradient(e, self)                 
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
164, in __init__                  
    color[3] = int(float(e.get('stop-opacity', '1')) * 255)               
                                  
TypeError: 'NoneType' object does not support item assignment             
                                  
[ERROR  ] unable to load ../svg/car.svg                                   
                                  
Traceback (most recent call last):                                        
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/ui/widgets/svg.py",
line 34, in __init__                 
    self.svg = squirtle.SVG(self.filename)                                
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
257, in __init__                  
    self.generate_disp_list()                                             
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
303, in generate_disp_list        
    self.parse_doc()                                                      
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
403, in parse_doc                 
    self.parse_element(e)                                                 
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
561, in parse_element             
    self.parse_element(c)                                                 
                                  
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
556, in parse_element
    self.gradients[e.get('id')] = LinearGradient(e, self)
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
164, in __init__
    color[3] = int(float(e.get('stop-opacity', '1')) * 255)
TypeError: 'NoneType' object does not support item assignment
[WARNING] trying
/usr/local/lib/python2.6/dist-packages/pymt/data/icons/svg../svg/car.svg
[ERROR  ] unable to load file ../svg/car.svg
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/pymt/ui/widgets/svg.py",
line 40, in __init__
    self.svg = squirtle.SVG(os.path.join(svgpath, self.filename))
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
257, in __init__
    self.generate_disp_list()
  File "/usr/local/lib/python2.6/dist-packages/pymt/lib/squirtle.py", line
297, in generate_disp_list
    if open(self.filename, 'rb').read(3) == '\x1f\x8b\x08': #gzip magic numbers
IOError: [Errno 2] No such file or directory:
'/usr/local/lib/python2.6/dist-packages/pymt/data/icons/svg/../svg/car.svg'
Traceback (most recent call last):
  File "svg.py", line 29, in <module>
    pymt_plugin_activate(w, ctx)
  File "svg.py", line 15, in pymt_plugin_activate
    car = MTScatterSvg(filename = '../svg/car.svg', pos = (380,300))
  File "/usr/local/lib/python2.6/dist-packages/pymt/ui/widgets/scatter.py",
line 409, in __init__
    self.squirt = MTSvg(filename=kwargs.get('filename'))
  File "/usr/local/lib/python2.6/dist-packages/pymt/ui/widgets/svg.py",
line 44, in __init__
    self.size = (self.svg.width, self.svg.height)
AttributeError: 'MTSvg' object has no attribute 'svg'
AL lib: ALc.c:1302: exit() 1 device(s) and 1 context(s) NOT deleted
Segmentation fault (core dumped)

What is the expected output? What do you see instead?

Expected SVG example to load the addition svg file

What version of the product are you using? On what operating system?

pymt-0.2
Please provide any additional information below.


Are there specific requirments for the SVG file - settings or limits on
size or width ETC?? 
May 29, 2009
Project Member #1 txprog
Yeah, squirtle don't implement the whole SVG spec.
I'll fix the color things anyway.
Status: Accepted
Owner: txprog
Jun 6, 2009
Project Member #2 txprog
(No comment was entered for this change.)
Status: Fixed
Labels: Milestone-0.3