Answer the question
In order to leave comments, you need to log in
What is the reason for the program's departure?
I apologize in advance - I'm still a newbie and I definitely don't know what to do.
I am writing an mp3 player. Everything seems to be going great. The play button in the middle calls the function of the same name:
def play():
global audiofile, mp3_lst, mp3_patch, \
plitem, title, song_time, lng, secs,\
mins, hours, div, div2, time_to_move
mp3_patch = mp3_lst[plitem]
audiofile = mutagen.File(dir + "\\" + mp3_patch)
title = mp3_patch[0:-4]
name_text.config(text=title)
lng = int(audiofile.info.length)
if lng >= 60:
div = divmod(lng, 60)
mins = div[0]
secs = div[1]
else:
mins = 0
secs = lng
if mins >= 60:
div2 = divmod(mins, 60)
hours = div2[0]
mins = div2[1]
else:
hours = 0
song_time = timedelta(minutes=mins,
seconds=secs,
milliseconds=hours)
time1_label.config(text=song_time)
time_to_move = (300-5-1) / lng
while time2_label['text'] != time1_label['text']:
time.sleep(1)
canvas.move(play_circle,
time_to_move,
0)
Answer the question
In order to leave comments, you need to log in
GUI events are handled by an infinite loop that starts when you call mainloop()
it. It cannot be stopped or the application will hang. And the loop while
and the call time.sleep(1)
do just that.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question