Apr-09-2021, 03:25 PM
I don't have a sense hat to work with but I can tell you that
My code below simply increments the values in
after ()
does not work like you think it would. The first time that you call canvas.after (500)
it will wait half a second but the next time you call it, it will not seem to work at all because it only waited the same half a second, not a whole second. To work with this you have to add time each time you call it.My code below simply increments the values in
orientationData
instead of getting it from the sense hat but the concept is the same. I hope this helps.from tkinter import * # Create a container for everything canvas = Tk() def UpdateOrientationDate(): #Reaquire the orientation data for key, value in orientationData.items () : orientationData [key] = value + 1 #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))) #Get intital orientation orientation data from the trycorder orientationData = {"pitch": 7, "roll": 8, "yaw": 9} # Pre-populate the Labels with data for orientation from the trycorder pitchLabel = Label(canvas, width = 9, text="0") rollLabel = Label(canvas, text="0") yowLabel = Label(canvas, text="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) wait_time = 0 for count in range (13) : wait_time += 500 canvas.after (wait_time, UpdateOrientationDate) canvas.mainloop()