~thomas-deruyter-3/qreator/qreator

« back to all changes in this revision

Viewing changes to qreator/QRCode.py

  • Committer: David Planella
  • Date: 2012-01-23 07:59:13 UTC
  • Revision ID: david.planella@ubuntu.com-20120123075913-nb6fscmlc8j3d2t1
Added support to display maps with libchamplain. python-osmgpsmap, as an alternative without Clutter, does not seem to work because it's not introspectable -gtk3 branch is still WIP. Commented out GSettings code, at it seems to crash Winpdb (settings schema not found)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
 
2
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
3
### BEGIN LICENSE
 
4
# This file is in the public domain
 
5
### END LICENSE
2
6
 
3
7
import qrencode
4
8
import Image
5
9
import ImageOps
6
10
import cairo
7
11
import array
8
 
import Geoclue
9
 
#import osmgpsmap
10
 
 
11
 
POS_PROVIDER = 'Ubuntu GeoIP'
12
 
 
13
 
#    self.osm = osmgpsmap.GpsMap()
14
 
 
15
 
#    self.osm.layer_add(
16
 
#                    osmgpsmap.GpsMapOsd(
17
 
#                        show_dpad=True,
18
 
#                        show_zoom=True))
19
 
#        self.osm.layer_add(
20
 
#                    DummyLayer())
21
12
 
22
13
 
23
14
class QRCodeSize(object):
28
19
 
29
20
class QRCode(object):
30
21
 
31
 
    def __init__(self, output_size = QRCodeSize.MEDIUM):
 
22
    def __init__(self, output_size=QRCodeSize.MEDIUM):
32
23
        self.output_size = output_size
33
24
        self.qrcode_size = 0
34
25
        self.pixel_size = 1
96
87
        border_size = (self.output_size - self.image.size[0]) / 2
97
88
        self.image = ImageOps.expand(self.image, border=border_size,
98
89
                                     fill='white')
99
 
 
100
 
 
101
 
def get_current_location():
102
 
    location = Geoclue.DiscoverLocation()
103
 
    location.init()
104
 
    location.set_position_provider(POS_PROVIDER)
105
 
    position = location.get_location_info()
106
 
    return position['latitude'], position['longitude']