Python Forum

Full Version: Messagebox with playsound
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to play sound(recorded sound of message in message box) with message box.

playsound('myrecord.wav')
messagebox.askquestion('Information',info)

But in this case sound is playing first and after completion of this task, message box appears.

messagebox.askquestion('Information',info)
playsound('myrecord.wav')

And in this case message box appears first and then sound plays after disappearing of message box.

But i want to play recorded sound with message box at the same time.
How can i achieve it?
Try this in Python 3:

from tkinter import messagebox
import winsound

winsound.Beep(2000, 300)
messagebox.showinfo("Beeping box", "This is a beeping messagebox!", icon = "info", parent = None)
Have you tried using a thread?
import threading

threading.Thread(target=playsound, args=('myrecord.wav',)).start()
messagebox.askquestion('Information',info)
Try this. You'll need to install pygame though.

from pygame import mixer
from tkinter import messagebox

mixer.init()

recording = mixer.Sound("myrecording.wav")

recording.play()
messagebox.showinfo("Try this", "it'll work", icon = "info", parent = None)
This'll defintely work try this first
Did my solution work?
Thank you. It works. Smile
:) I'll be happy to give you more help if needewd!