Jun-27-2021, 01:40 PM
Hi,
I need to know how to get the value of the first item in the listbox?
I need to know how to get the value of the first item in the listbox?
song_box.select_set(0)I think this will only make the selection of the first item. I need to play music of playlist. after reaching the end of the list I need to move the path to the first item so it can replay from start again.
last_value = song_box.get("end") if song == last_value and converted_current_time == converted_song_length: thefirst = song_box.select_set(0) pygame.mixer.music.load(thefirst) pygame.mixer.music.play(loops=0) elif song != last_value and converted_current_time == converted_song_length: next_song()the second statement is working since i am not reaching the end of the playlist it will go to the next item in the list.
def next_song(): global paused if paused==True: paused = False play() #get current file in the list next_one = song_box.curselection() # get next file in the list next_one = next_one[0] + 1 #assign the next file in the list song = song_box.get(next_one) #load and play the file pygame.mixer.music.load(song) pygame.mixer.music.play(loops=0) # clear active bar in play list song_box.select_clear(0, END) # activate bar in play list song_box.activate(next_one) # set the active bar to next file song_box.selection_set(next_one,last=None)Thanks