GUIs - A Modest Proposal

Arndt Roger Schneider arndt.roger at addcom.de
Tue Jun 8 04:50:34 EDT 2010


Terry Reedy schrieb:

> On 6/7/2010 5:25 PM, Arndt Roger Schneider wrote:
>
>> Terry Reedy schrieb:
>
> ...
>
>> Hah, You are ill-informed.
>
>
> How about 'under-informed'? That I readily admit ;-)
>
>> tkpath 0.3 contains a surface element, which renders vector graphics
>> elements in an off-screen tk image.
>
>
> As far as I know, tkpath is either not part of the tk that comes with 
> python, or not accessible via tkinter, or not documented.
>


3x Correct. Tkpath 0.2 is a plugin into tk canvas.
Tkpath 0.3 is a standalone replecement for tk canvas.
The tkpath interface is identical to tk canvas, but it features additional
objects: path, polyline, ppolygon, pline, ptext, circle, ellipse, radial 
gradients,
linear gradients, groups and styles.


The original tk canvas elements are the same as with tkpath,
but the new elements are the tk counterpart to those elements listed inside
the svg 1.1 specification.

As for documentation;
Use the Jeszra book, the svg 1.1 specification and the
ascii text documentation distributed with tkpath.

tkpath bypasses the X-emulation layer for the new elements under Windows
and OSX. CAIRO is the backend under X11.


>> Forget postscript!
>
>
> Gladly!
>
>> Generate SVG from a tk canvas or --better-- from tkpath.
>> Jeszra (from me) generates SVG.
>
>
> I found http://jeszra.sourceforge.net/
> It looks interesting but not quite what I need, which is to export a 
> tk canvas that I draw on with Python in a form I can import into 
> OpenOffice.
>
OpenOffice does --not yet-- have an svg import filter.
You will have to convert SVG into another format.

For example: use a fo-wrapper around your SVG and convert this
fo-xml into pdf (fop / java).

Other options are: inkscape, adobe illustrator,
gimp--if you can life with a raster image.


I guess SVG import has highest priority within the OpenOffice project
--you wont need such workarounds for long.


>  There is also a SVG export
>
>> package available in python/tkinter, search the tkinter wiki.
>
>
> I presume you mean there is a 3rd party python add-on package that 
> exports from a tk canvas. Can you be more specific as to what you meant?
>
> Googling 'tkinter wiki' got me to http://tkinter.unpythonic.net/wiki/
> wiki.python.org/moin/TkInter has a link to the same.
> Searching there for 'svg' title or text has no hits.
> Searching PyPI also turns up nothing obvious.
>
> Googling further, I found canvasvg.py at
> http://wm.ite.pl/proj/canvas2svg/index.html
> via an answer to a question at
> http://bytes.com/topic/python/answers/629332-saving-output-turtle-graphics 
>
> I will give it a try.
>
> Terry Jan Reedy
>
That was it! Be aware only tk canvas elements are exported to SVG by this
package. Jeszra on the other hand converts an entire GUI into SVG.
I don't have any experience with this python package--for obvious reasons.
What you should look after is how raster images are included in the
generated SVG; and try each of the 12 different arrow shapes for tk line.


If you have controls on your canvas:
You may use the screenshot facility of tkImg to create an
image from each control, then embed the screenshot base64 encoded
inside the generated SVG.-


-roger



More information about the Python-list mailing list