File: hyperlink.py

package info (click to toggle)
svgwrite 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,304 kB
  • sloc: python: 12,524; makefile: 116; sh: 5
file content (27 lines) | stat: -rw-r--r-- 736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
#coding:utf-8
# Author:  mozman
# Purpose: svg hyperlink examples
# Created: 05.05.2017
# Copyright (C) 2017, Manfred Moitzi
# License: MIT License
try:
    import svgwrite
except ImportError:
    # if svgwrite is not 'installed' append parent dir of __file__ to sys.path
    import sys
    from pathlib import Path
    sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

import svgwrite


def hyperlink(name):
    dwg = svgwrite.Drawing(name, (200, 200), debug=True)
    # use the hyperlink element
    link = dwg.add(dwg.a('http://www.w3.org'))
    link.add(dwg.ellipse(center=(100, 50), r=(50, 25), fill='red'))
    dwg.save(pretty=True)

if __name__ == '__main__':
    hyperlink("hyperlink.svg")