Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use SVG DOM in Python

Tags:

python

dom

svg

This question may sounds dumb, but I can't manage to find a correct answer on my own. I am trying to use the SVG DOM interface in my python script. I would like to use getComputedTextLength but I can't find how even if I firstly thought it would be available thanks to modules or a packages like python-svg or something like that. I am sure there is something I miss, but I can't find what.

Any help would be appreciated. Thank you.

EDIT: I forgot to talk about what my script actually does. It's a Python script used to generate a SVG file from data grabbed on the Internet. My script needs to write texts and repeat them all along a path. Also, as I know the exact length (in pixels) of the path I need to know the length of the text in order to repeat it only what I need to. That's why a method like getComputedTextLength would be helpful.

like image 285
lvictorino Avatar asked Jul 06 '11 21:07

lvictorino


People also ask

Can Python access the DOM?

To access the JavaScript DOM, we will be using a Python package called “JyServer.” You can simply install it with pip like this. Of course, you will also need Flask installed, which you can install like this.

What is SVG in Python?

In this article we will see how we can create SVG file using PyCairo in Python. SVG : An SVG file is a graphics file that uses a two-dimensional graphic vector format that defines images using an XML-based text format. As a standard format for showing vector graphics on the web, SVG files are developed.


1 Answers

Try this: http://www.gnu.org/software/pythonwebkit/

like image 151
Marcin Avatar answered Nov 07 '22 18:11

Marcin