Python: winsound.PlaySound during tk mainloop()

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
Loki
Forum Commoner
Posts: 25
Joined: Wed Jun 03, 2009 9:23 pm

Python: winsound.PlaySound during tk mainloop()

Post by Loki »

I've got a program that uses root.mainloop() to display a Tk drawn window, and uses winsound.PlaySound() to play a wav file automatically. However, if I place the winsound object before the mainloop, the window wont open until the sound is done playing. If I place it after, the sound wont play until I close the window. I just want the sound to automatically play when the window opens.
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Python: winsound.PlaySound during tk mainloop()

Post by andyhoneycutt »

I've only done a bit with python, and at that only mathematical solutions (Go Project Euler!)

Take a look at the documentation for the method you're calling: from the Python Docs website

To me, it would appear that you need to try a couple of things to at least trouble-shoot further:
Try forcing the sound to play asynchronously. This will at least allow other things (at least sounds) to go on while this sound is still playing.
If that fails, try setting the SND_NOWAIT flag just to be sure your sound driver isn't holding up the system (which I doubt in this case).

Sorry I couldn't be more helpful, hope this gets you in the right direction at least!

-Andy
Post Reply