Advertisement
fmasanori

Show Calouros GUI Final

Oct 11th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. from tkinter import *
  2. app = Tk()
  3. app.title("Show de calouros")
  4. app.geometry('300x100+200+100')
  5. import pygame.mixer
  6. sounds = pygame.mixer
  7. sounds.init()
  8. certos = IntVar()
  9. certos.set(0)
  10. errados = IntVar()
  11. errados.set(0)
  12. def espera_tocar(canal):
  13.     while canal.get_busy():
  14.         pass
  15. def musica_certa():
  16.     s = sounds.Sound("correct.wav")
  17.     espera_tocar(s.play())
  18.     certos.set(certos.get() + 1)
  19. def musica_errada():
  20.     s = sounds.Sound("wrong.wav")
  21.     espera_tocar(s.play())
  22.     errados.set(errados.get() + 1)        
  23. lab = Label(app, text='Aperte os botões!', height = 3)
  24. lab.pack()
  25. lab1 = Label(app, textvariable = certos)
  26. lab1.pack(side = 'left')
  27. lab2 = Label(app, textvariable = errados)
  28. lab2.pack(side = 'right')
  29. b1 = Button(app, text = "Certo!", width = 10, command = musica_certa)
  30. b1.pack(side = "left", padx = 10, pady = 10)
  31. b2 = Button(app, text = "Errado!", width = 10, command = musica_errada)
  32. b2.pack (side = "right", padx = 10, pady = 10)
  33. app.mainloop()        
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement