Example #1
0
    def start(self, startMainLoop=False):
        if startMainLoop:
            from PySide.QtCore import QCoreApplication

            self.qtApplication = QCoreApplication(sys.argv)
            # we import QGeoPositionInfoSource after the Qt Application is
        # created to get rid of the:
        # "
        # QDBusConnection: system D-Bus connection created before QCoreApplication. Application may misbehave.
        # QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
        # "
        # warnings
        from QtMobility.Location import QGeoPositionInfoSource

        self.source = QGeoPositionInfoSource.createDefaultSource(None)
        if self.source is not None:
            self.source.positionUpdated.connect(self._positionUpdateCB)
            log.info("position source created")
            # TODO: custom interval setting
            self.source.setUpdateInterval(1000)
            self.source.startUpdates()
            log.info("started")

            # only start the mainloop if the source was created successfully,
            # otherwise it would never end as the signal provided by the source,
            # that stops the main loop, would never be triggered
            if startMainLoop:
                log.info("starting headless mainloop")
                self.qtApplication.exec_()
        else:
            log.error("source creation failed")
Example #2
0
    def start(self, startMainLoop=False):
        if startMainLoop:
            from PySide.QtCore import QCoreApplication

            self.qtApplication = QCoreApplication(sys.argv)
            # we import QGeoPositionInfoSource after the Qt Application is
        # created to get rid of the:
        # "
        # QDBusConnection: system D-Bus connection created before QCoreApplication. Application may misbehave.
        # QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
        # "
        # warnings
        from QtMobility.Location import QGeoPositionInfoSource

        self.source = QGeoPositionInfoSource.createDefaultSource(None)
        if self.source is not None:
            self.source.positionUpdated.connect(self._positionUpdateCB)
            print("location Qt Mobility: position source created")
            # TODO: custom interval setting
            self.source.setUpdateInterval(1000)
            self.source.startUpdates()
            print("location qt mobility: started")

            # only start the mainloop if the source was created successfully,
            # otherwise it would never end as the signal provided by the source,
            # that stops the main lopp, would never be triggered
            if startMainLoop:
                print("location qt mobility: starting headless mainloop")
                self.qtApplication.exec_()
        else:
            print("location Qt Mobility: source creation failed")
Example #3
0
  def __init__(self, location):
    PositionSource.__init__(self, location)

    # connect to QT Mobility position source
    self.source = QGeoPositionInfoSource.createDefaultSource(None)
    if self.source != None:
      self.source.positionUpdated.connect(self._positionUpdateCB)
      print("location Qt Mobility: position source created")
    else:
      print("location Qt Mobility: source creation failed")