Advertisement
horozov86

status_bar duration

Jun 24th, 2024 (edited)
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. status_bar = Label(root, text="", bd=1, relief=GROOVE, anchor=E)
  2. status_bar.pack(fill=X, side=BOTTOM, ipady=2)
  3.  
  4.  
  5. def play_time():
  6.     current_time = pygame.mixer.music.get_pos() / 1000
  7.    
  8.     converted_current_time = time.strftime("%M:%S", time.gmtime(current_time))
  9.    
  10.     current_song = song_box.curselection()
  11.    
  12.     song = song_box.get(current_song)
  13.    
  14.     song = f"C:/gui/audio/{song}.mp3"
  15.    
  16.     song_mut = MP3(song)
  17.    
  18.     song_length = song_mut.info.length
  19.    
  20.     converted_song_length = time.strftime("%M:%S", time.gmtime(song_length))
  21.    
  22.     status_bar.config(text=f"Time Elapsed: {converted_current_time} of {converted_song_length}  ")
  23.    
  24.     status_bar.after(1000, play_time)
  25.    
  26. # В края на функцията stop добави
  27. # status_bar.config(text="")
  28.  
  29. # и промени song = song_box.get(current_song) на song = song_box.get(ACTIVE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement