You might have an answer to my question. I am trying to create a script which will gather gps data and output the data to a textbox or label on my dialog screen. I have come up with this so far but I cannot get the label text to accept my entry. I have highliged my trouble area. If you have a better solution, please assist.
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Licence: GPL v.3 http://www.gnu.org/licenses/gpl.html
# This is an XBMC addon for demonstrating the capabilities
# and usage of PyXBMCt framework.
import os
import sys
import time
import xbmc, xbmcaddon, xbmcgui
from pyxbmct.addonwindow import *
from gps import *
import threading
import subprocess
_addon = xbmcaddon.Addon()
_addon_path = _addon.getAddonInfo('path')
gpsd = None #seting the global variable
os.system('clear') #clear the terminal (optional)
class MyAddon(AddonDialogWindow):
def __init__(self, title=''):
super(MyAddon, self).__init__(title)
self.setGeometry(1200, 750, 10, 3)
self.set_info_controls()
self.set_active_controls()
# Connect a key action (Backspace) to close the window.
self.connect(ACTION_NAV_BACK, self.close)
def set_info_controls(self):
label_center = Label ("Time")
self.placeControl(label_center, 1,1)
print "check 1"
def set_active_controls(self):
int_label = Label('Interactive Controls', alignment=ALIGN_CENTER)
self.placeControl(int_label, 0, 2, 1, 2)
print "check 2"
# start_button_update
self.button = Button('Close')
self.placeControl(self.button, 8, 2)
# Connect control to close the window.
self.connect(self.button, self.close)
print "check 3"
# Update button caption on toggle
[b]time_label = Label(GpsPoller.gpstime, alignment=ALIGN_CENTER)
[/b] self.placeControl(int_label, 3, 1)
print "check 4"
class GpsPoller(threading.Thread):
print "check 5"
def __init__(self):
threading.Thread.__init__(self)
global gpsd #bring it in scope
gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
self.current_value = None
self.running = True #setting the thread running to true
print "check 6"
def run(self):
print "check 7"
global gpsd
while gpsp.running:
gpsd.next() #this will continue to loop and grab EACH set of gpsd info to clear the buffer
print "check 8"
def gpstime(self):
global line1
line1 = 'time utc ' , gpsd.utc,' + ', gpsd.fix.time
try:
print "A"
while True:
print "B"
#It may take a second or two to get good data
#print gpsd.fix.latitude,', ',gpsd.fix.longitude,' Time: ',gpsd.utc
os.system('clear')
#print
#print ' GPS reading'
#print '----------------------------------------'
#print 'latitude ' , gpsd.fix.latitude
#print 'longitude ' , gpsd.fix.longitude
line1 = 'time utc ' , gpsd.utc,' + ', gpsd.fix.time
#print 'time utc ' , gpsd.utc,' + ', gpsd.fix.time
#print 'altitude (m)' , gpsd.fix.altitude
#print 'eps ' , gpsd.fix.eps
#print 'epx ' , gpsd.fix.epx
#print 'epv ' , gpsd.fix.epv
#print 'ept ' , gpsd.fix.ept
#print 'speed (m/s) ' , gpsd.fix.speed
#print 'climb ' , gpsd.fix.climb
#print 'track ' , gpsd.fix.track
#print 'mode ' , gpsd.fix.mode
#print
#print 'sats ' , gpsd.satellites
print "check C"
time.sleep(5)
except (KeyboardInterrupt, SystemExit):
#when you press ctrl+c
print "\nKilling Thread..."
gpsp.running = False
gpsp.join() # wait for the thread to finish what it's doing
print "Done.\nExiting."
if __name__ == '__main__':
gpsp = GpsPoller() # create the thread
window = MyAddon('PyXBMCt Demo')
window.doModal()