Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. from tkinter import *
  2. from random import *
  3. score_joueur = 0 #Score du joueur ,init a 0
  4.  
  5. def start():
  6. print("start")
  7. reset()
  8. nb_couleur = []
  9. print(nb_couleur)
  10. tirage(nb_couleur)
  11. print(nb_couleur)
  12.  
  13. def reset():
  14. print("reset")
  15. info_score(score_joueur,False)
  16. actu_texte(tour,1)
  17.  
  18. def tirage(nb_couleur):
  19. print("tirage")
  20. nb_couleur.append(randint(0,3))
  21.  
  22. def info_score(score_joueur,info):
  23. if info:
  24. score_joueur = score_joueur + 1
  25. else:
  26. score_joueur = 0
  27. score.configure(text="Votre score: " + str(score_joueur))
  28.  
  29. def actu_texte(tour,num):
  30. tour.configure(text=TOURPOUR[num])
  31.  
  32. def flash(nb):
  33. print("premierrrrrrrrrrrrrrrrrr")
  34. if nb == 0:
  35. btn.config(state="active")
  36. btn.after(100,flash_end(0))
  37. elif nb == 1:
  38. btn2.config(state="active")
  39. btn.after(100,flash_end(1))
  40. elif nb == 2:
  41. btn3.config(state="active")
  42. btn3.after(100,flash_end(2))
  43. elif nb == 3:
  44. btn4.config(state="active")
  45. btn4.after(100,flash_end(3))
  46.  
  47. def flash_end(nb):
  48. print("flashhhhhhhhhhhhhhhh")
  49. if nb == 0:
  50. btn.config(state="normal")
  51. elif nb == 1:
  52. btn2.config(state="normal")
  53. elif nb == 2:
  54. btn3.config(state="normal")
  55. elif nb == 3:
  56. btn4.config(state="normal")
  57.  
  58.  
  59. nb_couleur = []
  60. COULEUR = ["rouge","bleu","jaune","vert"]
  61. TOURPOUR = ["Clique sur commencer pour jouer","C'est a votre tour de jouer","Patience"]
  62. root=Tk()
  63. root.title("Jeu de Simon")
  64. root.resizable(False, False)
  65. tour = Label(text=str(TOURPOUR[0]),font=10)
  66. tour.grid(row=0,column=0,columnspan=2,sticky="")
  67. btn=Button(root,width=20,height=14,bg="#EE575B",activebackground="red")
  68. btn.grid(row = 1,sticky="e")
  69. btn2=Button(root,width=20,height=14,bg="#61A1CA",activebackground="blue")
  70. btn2.grid(row=1,column=1,sticky="w")
  71. btn3=Button(root,width=20,height=14 ,bg="#65E265",activebackground="green")
  72. btn3.grid(row=2,column=0,sticky="e")
  73. btn4=Button(root,width=20,height=14,bg="#FFE772",activebackground="yellow")
  74. btn4.grid(row=2,column=1,sticky="e")
  75. score = Label(text="Votre score: " + str(score_joueur),font=10)
  76. score.grid(row=3,column=0,sticky="w")
  77. btn_start = Button(root,text="COMMENCER",width=16,height=1,bg="white",font="Helvetica",fg="#7A4A4B",command=start)
  78. btn_start.grid(row=3,column=1)
  79.  
  80. btn4.after(1000,flash(2))
  81. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement