Reputation: 179
Iam building a project tkinter. Here my Code
from tkinter import *
screen=Tk()
screen.geometry('500x300+400+200')
def play():
from playsound import playsound
playsound("music.mp3")
screen.title("Simple project")
btn=Button(screen,text='play',width=20,command=play).place(x=340,y=260)
screen.mainloop()
And when I click button "play" then tkinter screen is Not responding.
So how can I fix it.
Thank you
Upvotes: 0
Views: 139
Reputation:
You can use threading
module.
from tkinter import *
from threading import Thread
screen=Tk()
screen.geometry('500x300+400+200')
def play():
from playsound import playsound
playsound("music.mp3")
def start_play():
t=Thread(target=play)
t.daemon=True
t.start()
screen.title("Simple project")
btn=Button(screen,text='play',width=20,command=start_play).place(x=340,y=260)
screen.mainloop()
Upvotes: 1