Hi all
This is my first post so I apologise if this post is in the wrong place
I have a raspberry pi and sense hat and would like to have Tkinter labels update various sensor readings automatically
I have the orientation sensor data I would like to display that data in real-time on the labels
I've tried many combinations but because I'm new to python I cannot get my head around how to update the labels automatically
hear is what I have so fare
This is my first post so I apologise if this post is in the wrong place
I have a raspberry pi and sense hat and would like to have Tkinter labels update various sensor readings automatically
I have the orientation sensor data I would like to display that data in real-time on the labels
I've tried many combinations but because I'm new to python I cannot get my head around how to update the labels automatically
hear is what I have so fare
from sense_hat import SenseHat from tkinter import * # Create a container for everything canvas = Tk() # Create a path to the sensors trycorder = SenseHat() def UpdateOrientationDate(): #Reaquire the orientation data orientationData = trycorder.get_orientation() #Update the labels with orientation data from the trycorder pitchLabel.config(text=str(round(orientationData["pitch"], 0))) rollLabel.config(text=str(round(orientationData["roll"], 0))) yowLabel.config(text=str(round(orientationData["yaw"], 0))) #Set Globals global pitchLabel global rollLabel global yowLabel #Get intital orientation orientation data from the trycorder orientationData = trycorder.get_orientation() # Pre-populate the Labels with data for orientation from the trycorder pitchLabel = Label(canvas, text=str(round(orientationData["pitch"], 0))) rollLabel = Label(canvas, text=str(round(orientationData["roll"], 0))) yowLabel = Label(canvas, text=str(round(orientationData["yaw"], 0))) #Place the labels on the grid pitchLabel.grid(row=0, column=0) rollLabel.grid(row=1, column=0) yowLabel.grid(row=2, column=0) #Call the function every 500ms canvas.after(500, UpdateOrientationDate) #Ive also tried this #while True: # #Reaquire the orientation data # orientationData = trycorder.get_orientation() # # #Update the labels with orientation data from the trycorder # pitchLabel.config(text=str(round(orientationData["pitch"], 0))) # rollLabel.config(text=str(round(orientationData["roll"], 0))) # yowLabel.config(text=str(round(orientationData["yaw"], 0))) canvas.mainloop()Any help or pointers would be welcomed