Reputation: 93
Is there a way to while playing winsound.PlaySound("some sound", FLAGS) also change a photolabel? I've been trying and no matter where I put the play sound it always play the sound before changing my photo label.
My code:
def thriller(self):
winsound.PlaySound("thriller.wav", winsound.SND_NODEFAULT)
img5 = ImageTk.PhotoImage(Image.open('thriller.jpg'))
self.photoLabel.configure(image = img5)
self.photoLabel.image = img5
self.original_board()
def original_board(self):
from PIL import Image, ImageTk
self.image = Image.open("board.jpg")
self.photo = ImageTk.PhotoImage(self.image)
self.photoLabel.after(5000, lambda: self.photoLabel.configure(image=self.photo))
Upvotes: 0
Views: 111
Reputation: 681
Yes you can. You have to play the sound asynchronly. The flag winsound.SND_ASYNC should do the work. If that does not help, you can spawn the winsound function in a new thread (or in python better a new process) such that it is played at the same time as the image changes.
Good luck!
Upvotes: 1