Bonsoir à tous,
Je suis en Terminale et en option j'ai pris Informatiques et sciences du numériques. Nous avons un projet à réaliser et j'ai choisis de faire un "des chiffres et des lettres" mais juste "des lettres"
Le fonctionnement du programme : J'ai deux boutons consonne et voyelle qui tire une lettre au hasard, de plus quand on appuie sur les boutons, on a une voix qui dit "consonne" ou "voyelle"
Pour mieux s’immerger dans le jeu !
Les lettres s'affichent et grâce à ces lettres on fait un mot. On valide puis grâce à une base de données on recherche si le mot est juste ! Puis on attribue les points !
Je rencontre un problème pour l'affiche des lettres qui sont choisis aléatoirement ! En fait je voudrais les afficher sur ma fenêtre avec un Label ! Mais je n'y arrive pas !
- ###############################################
- ########################################
from Tkinter import*
import pygame
import random
random.randint(0,5)
fenetre = Tk()
fenetre.geometry('400x200+500+500')
global voyelles
voyelles=["A","E","I","O","U","Y"]
global consonnes
consonnes=["B","C","D","F","G","H","J","K","L","M"
,"N","P","Q","R","S","T","V","W","X","Z"]
global lettres
lettres = StringVar()
- ARBORESCENCE DES FENETRES#
fenetre.title("DES LETTRES")
fenbouton = Frame(fenetre)
fenmot = Frame(fenetre)
- FENETRE D'ECRITURE#
ligne_texte = Frame(fenetre, width=10, height=20, borderwidth=1)
var_texte = StringVar()
ligne_texte = Entry(fenmot, textvariable=var_texte, width=15)
tirage = Label(fenmot, textvariable = lettres)
- SON BOUTON#
pygame.mixer.init()
son1 = pygame.mixer.Sound("voyelle.wav")
def affichervoyelle():
son1.play()
lettres=[]
lettres=lettres+[(voyelles[random.randint(0,5)])]
tirage.set('** ' + str(lettres))
son2 = pygame.mixer.Sound("consonne.wav")
def afficherconsonne():
son2.play()
lettres=[]
lettres=lettres+[(consonnes[random.randint(0,19)])
]
tirage.set('** ' + str(lettres))
- BOUTON#
bouton_voyelle = Button(fenbouton, text="Voyelle", bg="red", fg="blue", command=affichervoyelle)
bouton_consonne = Button(fenbouton, text="Consonne", bg="blue", fg="red", command=afficherconsonne)
bouton_quitter = Button(fenetre, text="Quitter", bg="orange", command=fenetre.destroy)
bouton_valider = Button(fenetre, text="Valider", bg="green", command=fenetre.quit)
bouton_effacer = Button(fenetre, text="Effacer", bg="red", command=fenmot.quit)
- POSE DES OBJETS#
fenbouton.pack(side="top")
fenmot.pack(side="bottom")
bouton_consonne.pack(side=LEFT,padx=5,pady=5)
ligne_texte.pack()
bouton_voyelle.pack(side=LEFT,padx=10,pady=10)
bouton_quitter.pack(side=LEFT,padx=10,pady=10)
bouton_effacer.pack(side=LEFT,padx=10,pady=10)
bouton_valider.pack()
tirage.pack()
fenetre.mainloop()
- ###############################################
- #####################################
Les fonctions "affichervoyelle" et "afficherconsonne" jouent un son et doivent tirer une lettre ! Mais je n'arrive pas à les afficher sur ma fenêtre.. Pouvez vous m'aider ? merci 