~ubuntu-branches/debian/squeeze/inkscape/squeeze

« back to all changes in this revision

Viewing changes to share/extensions/render_barcode.py

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''
 
2
Copyright (C) 2007 Martin Owens
 
3
 
 
4
This program is free software; you can redistribute it and/or modify
 
5
it under the terms of the GNU General Public License as published by
 
6
the Free Software Foundation; either version 2 of the License, or
 
7
(at your option) any later version.
 
8
 
 
9
This program is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
GNU General Public License for more details.
 
13
 
 
14
You should have received a copy of the GNU General Public License
 
15
along with this program; if not, write to the Free Software
 
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
'''
 
18
 
 
19
import inkex
 
20
import sys
 
21
from Barcode import getBarcode
 
22
 
 
23
class InsertBarcode(inkex.Effect):
 
24
        def __init__(self):
 
25
                inkex.Effect.__init__(self)
 
26
                self.OptionParser.add_option("-l", "--height",
 
27
                                                action="store", type="int",
 
28
                                                dest="height", default=30,
 
29
                                                help="Barcode Height")
 
30
                self.OptionParser.add_option("-t", "--type",
 
31
                                                action="store", type="string",
 
32
                                                dest="type", default='',
 
33
                                                help="Barcode Type")
 
34
                self.OptionParser.add_option("-d", "--text",
 
35
                                                action="store", type="string",
 
36
                                                dest="text", default='',
 
37
                                                help="Text to print on barcode")
 
38
 
 
39
        def effect(self):
 
40
                x, y = self.view_center
 
41
                object = getBarcode( self.options.type, {
 
42
                        'text'     : self.options.text,
 
43
                        'height'   : self.options.height,
 
44
                        'document' : self.document,
 
45
                        'x'        : x,
 
46
                        'y'        : y,
 
47
                } )
 
48
                if object:
 
49
                        barcode = object.generate()
 
50
                        if barcode:
 
51
                                self.current_layer.append(barcode)
 
52
                        else:
 
53
                                sys.stderr.write("No barcode was generated\n")
 
54
                else:
 
55
                        sys.stderr.write("Unable to make barcode with: " + str(self.options) + "\n")
 
56
 
 
57
e = InsertBarcode()
 
58
e.affect()
 
59