This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

python-geoclue

python-geoclue is a Geoclue python module. This module does not implement python bindings in Geoclue. Maybe it will sometime in the future.
This module uses the Geoclue D-Bus API to implement a nice API for python developers and facilitate their life.

Where to get it

How to install it

Python-geoclue is available in all major distributions. Use the application installer software for your distro to install the python-geoclue package.

From the source it can be installed by running (this example is valid in Ubuntu, in other distros the root access method might be different):

How to use it

There is a test file (test.py) in a folder named tests/ that is available with the source. This file provides examples of how you can use all or almost all the methods available.

The API for the existing methods is available here.

Example

   1 import Geoclue
   2 
   3 # Note: this program will work in Ubuntu without
   4 # the need to install any additional packages, but for 
   5 # other distributions you'll need to install a suitable
   6 # position provider. In Debian and Ubuntu you can
   7 # add additional providers by installing the geoip-*
   8 # packages
   9 POS_PROVIDER = 'Ubuntu GeoIP'
  10 
  11 location = Geoclue.DiscoverLocation()
  12 location.init()
  13 location.set_position_provider(POS_PROVIDER)
  14 position = location.get_location_info()
  15 
  16 print position['latitude']
  17 print position['longitude']

2024-10-23 10:58