~thomas-deruyter-3/qreator/qreator

« back to all changes in this revision

Viewing changes to qreator/QRCode.py

  • Committer: David Planella
  • Date: 2012-05-23 12:58:45 UTC
  • mto: This revision was merged to the branch mainline in revision 67.
  • Revision ID: david.planella@ubuntu.com-20120523125845-7589t51mtsj44kjm
Started using the gettext C API (locale module) instead of the Python one (gettext module), so that translations are loaded when installing the app in /opt. See http://askubuntu.com/questions/140552/how-to-make-glade-load-translations-from-opt. Minor whitespace fixes. Removed shebang from QRCode.py to stop Lintian complaining

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
2
### BEGIN LICENSE
4
3
# Copyright (C) 2012 David Planella <david.planella@ubuntu.com>
27
26
    MEDIUM = 230
28
27
    LARGE = 350
29
28
 
 
29
 
30
30
class QRCodeOutput(object):
31
31
    PIL_IMAGE = 0
32
32
    CAIRO_SURFACE = 1
33
33
 
 
34
 
34
35
class QRCode(object):
35
36
 
36
37
    def __init__(self, output_size=QRCodeSize.MEDIUM):
42
43
 
43
44
    def encode(self, text, output_type=QRCodeOutput.PIL_IMAGE):
44
45
        '''Encodes the given text and returns a QR code in the given format'''
45
 
        
 
46
 
46
47
        if output_type == QRCodeOutput.PIL_IMAGE:
47
48
            qr_code = self._encode_to_pil(text)
48
49
        elif output_type == QRCodeOutput.CAIRO_SURFACE: