-
Notifications
You must be signed in to change notification settings - Fork 1
/
hello.py
31 lines (27 loc) · 952 Bytes
/
hello.py
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
28
29
30
31
import inkex
from inkex import TextElement
class Hello(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument('--name', type=str, default='Inkscape',
dest='name', help="name input")
def effect(self):
name = 'Hello ' + self.options.name
layer = self.svg.get_current_layer()
x = self.svg.unittouu('40px')
y = x
layer.add(self.add_text(x, y, name))
# self.debug('...end of effect method')
def add_text(self, x, y, text):
"""Add a text label at the given location"""
elem = TextElement()
elem.text = str(text)
elem.style = {
'font-size': self.svg.unittouu('18pt'),
'fill-opacity': '1.0',
'stroke': 'none',
'font-weight': 'normal',
'font-style': 'normal' }
elem.update(x=str(x), y=str(y))
return elem
if __name__ == '__main__':
Hello().run()