2. Pero la canción no termina…¶

from tkinter import *
import pygame.mixer
app = Tk()
app.title('DJ Mix')
app.geometry('250x100+200+100')
som = '50459_M_RED_Nephlimizer.wav'
mixer = pygame.mixer
mixer.init()
def start():
track.play(loops = -1)
def stop():
track.stop()
def termina():
track.stop()
app.destroy()
track = mixer.Sound(som)
start_botao = Button(app, command = start, text = 'Start')
start_botao.pack(side = LEFT)
stop_botao = Button(app, command = stop, text = 'Stop')
stop_botao.pack(side = RIGHT)
app.protocol('WM_DELETE_WINDOW',terminal)
app.mainloop()
2.1. Un solo botón¶

from tkinter import *
import pygame.mixer
app = Tk()
app.title('DJ Mix')
app.geometry('250x100+200+100')
som = '50459_M_RED_Nephlimizer.wav'
mixer = pygame.mixer
mixer.init()
def termina():
track.stop()
app.destroy()
def muda():
if tocando.get() == 1:
track.play(loops = -1)
else:
track.stop()
track = mixer.Sound(som)
tocando = IntVar()
tocar = Checkbutton(app,variable = tocando, command = muda, text = som)
tocar.pack()
app.protocol('WM_DELETE_WINDOW',terminal)
app.mainloop()
You have attempted of activities on this page