You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been on this for days. Basically i am trying to return the latitude and longitude values. The output works, the problem is that is outputs double even if i put a sleep time limit of 3 or 5 seconds. Is there a way to have the return value of print_locations only return one set of latitude and longitude? I am obviously doing something wrong.
code:
from kivy.lang import Builder
from plyer import gps
from kivy.app import App
from kivy.properties import StringProperty
from kivy.clock import Clock, mainthread
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.popup import Popup
import time
def gpsstart(self):
self.gps = gps
self.gps.start()
time.sleep(5)
self.gps.stop()
class MyScreenManager(ScreenManager):
pass
class GpsTestScreen(Screen):
pass
class GpsTestBoxLayout(BoxLayout):
gps_location = StringProperty()
def __init__(self, **kwargs):
super(GpsTestBoxLayout, self).__init__(**kwargs)
#self.cols = 1
self.spacing=40
self.padding=40
self.add_widget(Button(text='Update and check logs', font_size=40, size_hint_y=None, height=80, on_press=gpsstart))
self.gps = gps
def on_location(self, **kwargs):
self.gps_location = '\n'.join(['{}={}'.format(k, v) for k, v in kwargs.items()])
def print_locations(**kwargs):
location = '{lat}, {lon}'.format(**kwargs)
#location = location.split(":")[-1]
print(location)
return location
self.test = TextInput(text='aim is to print the latest location is here\nbut "print_locations" outputs double', multiline=True, size_hint_y=None, height=160, padding=30)
self.add_widget(self.test)
try:
self.gps.configure(on_location=print_locations)
except NotImplementedError:
import traceback
traceback.print_exc()
self.gps_status = 'GPS is not implemented for your platform'
kv = Builder.load_string('''
#:import NoTransition kivy.uix.screenmanager.NoTransition
#:import sys sys
MyScreenManager:
transition: NoTransition()
GpsTestScreen:
ActionBar:
pos_hint: {'top':1}
ActionView:
ActionPrevious:
with_previous: False
<GpsTestScreen>:
name: 'gps'
BoxLayout:
GpsTestBoxLayout
orientation: 'vertical'
padding: [50,10,50,10]
spacing: 10
size_hint_y: 0.8
Label:
text: "[color=000000]test[/color]"
markup: True
''')
class ScreenManagerApp(App):
def build(self):
return kv
ScreenManagerApp().run()
Hi,
I've been on this for days. Basically i am trying to return the latitude and longitude values. The output works, the problem is that is outputs double even if i put a sleep time limit of 3 or 5 seconds. Is there a way to have the return value of
print_locations
only return one set of latitude and longitude? I am obviously doing something wrong.code:
Logs showing double output for every press of a button:
I/python (22734): [INFO ] [Android ] discard joystick <0> cause no button
I/python (22734): [INFO ] [Android ] create joystick <1>
I/python (22734): [INFO ] [Android ] create joystick <2>
I/python (22734): [INFO ] [Android ] create joystick <3>
I/python (22734): [INFO ] [Android ] create joystick <4>
I/python (22734): [INFO ] [Android ] create joystick <5>
I/python (22734): [INFO ] [Android ] create joystick <6>
I/python (22734): [INFO ] [Android ] create joystick <7>
I/python (22734): [INFO ] [Android ] create joystick <8>
I/python (22734): [INFO ] [Android ] create joystick <9>
I/python (22734): [INFO ] [Android ] create joystick <10>
I/python (22734): [INFO ] [Android ] create joystick <11>
I/python (22734): [INFO ] [Android ] create joystick <12>
I/python (22734): [INFO ] [Android ] create joystick <13>
I/python (22734): [INFO ] [Android ] create joystick <14>
I/python (22734): [INFO ] [Android ] create joystick <15>
I/python (22734): [INFO ] [Android ] create joystick <16>
I/python (22734): -26.0717071, 27.9787612
I/python (22734): -26.0717071, 27.9787612
I/python (22734): -26.0716552, 27.9788069
I/python (22734): -26.0716552, 27.9788069
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: