Python Forum
[Tkinter] Can't get progressbar to update
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Can't get progressbar to update
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] progressbar DPaul 9 2,857 Sep-01-2021, 12:50 PM
Last Post: deanhystad
  Progressbar with start and stop jelo34 3 4,966 Nov-30-2020, 03:36 AM
Last Post: deanhystad
  [Tkinter] Progressbar value update issue Roshan 7 3,323 Apr-22-2020, 04:02 PM
Last Post: deanhystad
  Adding Progressbar to button aniyanetworks 9 10,010 Feb-07-2019, 11:12 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020