I have the following script which outputs altitude data from the gpsd module to the console and keeps it up to date. I would like to display the same data within a tkinter interface but whatever i've tried I can't seem to get it to refresh the data like the console does. It outputs the initial data ok but doesn't give me the latest data. I'm very much a novice so maybe i'm doing something stupid.
I've attached the initial code that just outputs to the console as that it what i'm basing it on.
Thanks, Dan.
import os
from gps import *
from time import *
import time
import threading
gpsd = None #seting the global variable
os.system('clear') #clear the terminal (optional)
class GpsPoller(threading.Thread):
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
def run(self):
global gpsd
while gpsp.running:
gpsd.next() #this will continue to loop and grab EACH set of gpsd info to clear the buffer
if __name__ == '__main__':
gpsp = GpsPoller() # create the thread
try:
gpsp.start() # start it up
while True:
os.system('clear')
print 'altitude (m)' , gpsd.fix.altitude
time.sleep(5) #set to whatever
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."