[Tkinter] Can't get progressbar to update - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] Can't get progressbar to update (/thread-24645.html) |
Can't get progressbar to update - frednet - Feb-24-2020 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? |