1
I can make the program play the music, but the whole window is without function and only comes back to work when the music stops, that is to say creating a def button to pause the button only becomes "clickable" when all the music stops.
from tkinter import *
from pygame import *
from pygame import mixer
jan = Tk()
jan.title("JANELAA")
jan.geometry('400x400')
class Sistema:
def __init__(self, box):
self.frame = Frame(box)
self.frame.pack()
self.menu = Menu(box)
self.menuFile = Menu(self.menu)
self.menuFile.add_command(label="Musicas" , command=self.msc)
self.menuFile.add_command(label="Notepad")
self.menu.add_cascade(label="File", menu=self.menuFile)
self.menuOption = Menu(self.menu)
self.menuOption.add_command(label="Calculadora")
self.menu.add_cascade(label="Options" , menu=self.menuOption)
box.config(menu=self.menu)
def msc(self):
lbl = Label(jan, text="MUSICA COLD BLOODED")
lbl.place(x=50, y=50)
def ok():
mixer.init()
mixer.music.load('coldb.mp3')
mixer.music.play(1 , 1)
while mixer.music.get_busy():
time.Clock().tick(10)
bt = Button(jan, text="TOCAR", command=ok)
bt.place(x=50, y=70)
Sistema(jan)
jan.mainloop()
Face vlw the program agr no longer need to wait for the music to end, however I’m still struggling to create the pause button, I do not understand how the event MOUSEBUTTONDOWN: says it is to pause but there is no pause button, and I had to add a -> : <- after envent.get() but it gives an error in the interpreter but I thank you since the problem I was giving was solved
– Marcos Lorhan
Like the pause button I created it does not just pause it for all the music and does not come back anymore when I click on the start button msm, I must create a button and apply functions to go back to where you left off?
– Marcos Lorhan
Dude, I had to create 3 buttons & #Xa
– Marcos Lorhan
the error was as follows: for Event in Event.get() : Unboundlocalerror: local variable 'Event' referenced before assignment
– Marcos Lorhan
Try to see if the error is not indentation. The reference to Event has to be inside the "for" loop, otherwise the interpreter does not "think" it.
– Luis Felipe