Feb-24-2020, 10:53 PM
I'm trying to create a program that uses a progress bar to show the CPU temperature and it works, but only once!
# importing tkinter module from tkinter import * from tkinter.ttk import * import subprocess # creating tkinter window root = Tk() # Progress bar widget root.progress = Progressbar(root, orient = HORIZONTAL, length = 100, mode = 'determinate') # Function responsible for the updating of the progress bar value def bar(): out = subprocess.Popen(['vcgencmd', 'measure_temp'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout,stderr = out.communicate() s=(stdout) value= (s[5:9]) f=float(value) print('Float Value =', f) root.progress['value'] = f root.progress.pack(pady = 10) # This doesn't work #while True: # bar() bar() root.mainloop()When I delete line 29
bar()and un-comment line 26 & 27
while True: bar()the window never even appears but the temperature does repeatedly update in the shell. What am I doing wrong?