Real Time Meter Update #3
Replies: 3 comments
-
@ShivashishPachauri |
Beta Was this translation helpful? Give feedback.
-
import random class GUI(): if name == "main": I'm trying to run above code where I want meter to update in real time, but it does not update. For summary, def ParsePacket() function generates random numbers, and what I expect is to get these random number updates on Meter in real time. Im also attaching zip file of this code, in case above code have indentation errors. I tried putting app.mainloop() outside of while loop but still it didnt work. |
Beta Was this translation helpful? Give feedback.
-
@ShivashishPachauri You are using while loop inside a tkinter-mainloop which will never work for updating any widget value. import random
import tkinter as tk
from tkdial import Meter
import threading
import time
class GUI():
def ParsePacket():
n = random.randint(-180, 180)
return n
def update():
while True:
z = GUI.ParsePacket()
meter1.set(z)
print(z)
time.sleep(1) # sleep for 1 second or else it will look weird
if __name__ == "__main__":
app = tk.Tk()
meter1 = Meter(app,start=-180, end=180, start_angle=260, end_angle=-340,
major_divisions=30,minor_divisions=5,fg="black", scale_color = "orange",needle_color="red",
text_font="DS-Digital 10", text_color="orange", state="disabled", scroll=False)
meter1.grid(padx=10, pady=10)
threading.Thread(target=update).start() # start this loop with threading
app.mainloop() |
Beta Was this translation helpful? Give feedback.
-
Hello Akascape, Great work for creating this library. I'm also interested to know if you have any feature to update the meter in real time based on some sensor value, for example Potentiometer.
Does command parameter does the above mentioned thing? if yes, can you guide me for that?
Beta Was this translation helpful? Give feedback.
All reactions