Python Forum
[Tkinter] Messagebox with playsound
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Messagebox with playsound
#1
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?
Reply
#2
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)
Reply
#3
Have you tried using a thread?
import threading

threading.Thread(target=playsound, args=('myrecord.wav',)).start()
messagebox.askquestion('Information',info)
Reply
#4
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
Reply
#5
Did my solution work?
Reply
#6
Thank you. It works. Smile
Reply
#7
:) I'll be happy to give you more help if needewd!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter messagebox and using datetime/timedelta Kaltex 3 3,336 Apr-07-2021, 06:23 PM
Last Post: Yoriz
  [Tkinter] Sound from the tkinter.messagebox tedarencn 2 5,936 Jul-11-2020, 10:45 AM
Last Post: steve_shambles
  [Tkinter] messagebox is not being executed please help erwinsiuda 2 2,303 Apr-02-2020, 01:56 AM
Last Post: Larz60+
  [Tkinter] passing data to messagebox kmusawi 0 1,811 Feb-18-2019, 01:51 AM
Last Post: kmusawi
  Adding timer on the Messagebox aniyanetworks 6 11,702 Feb-13-2019, 07:48 PM
Last Post: aniyanetworks
  [Tkinter] Button widget gets stuck from using tkinter.messagebox? Nwb 2 3,909 Jun-20-2018, 02:21 PM
Last Post: Nwb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020