1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
from tkinter import*
import random
from tkinter import Entry
from tkinter import END
fenetre = Tk()
fenetre.title("Jeu des lettres")
fenetre.geometry("500x600")
def topLevel(): #Nouvelle fenêtre qui s'ouvre pour afficher la description du jeu
top=Toplevel()
top.title("Description")
top.geometry("400x300")
txt_descri= Label(top, text= "Introduire vraie description", font=('Times', 15))
txt_descri.place(x=30,y=10)
def get_entry_data(): #commande qui sert à récupérer les caractères introduits par le joueur
data = entry_widget.get()
entry_widget.delete(0, END)
print(str(data))
rows = 0
while rows < 10:
fenetre.rowconfigure(rows, weight=1)
fenetre.columnconfigure(rows,weight=1)
rows += 1
entry_widget = Entry(fenetre)
entry_widget.place(x=190,y=350)
btn_valider= Button(fenetre)
btn_valider.configure(text='Valider', command=get_entry_data)
btn_valider.place(x=220,y=400)
def choisir(): #commande qui sert a tirer au sort 10 caractères de ma_liste
global btn_choisir
btn_choisir.config(text= random.sample(ma_liste, 10))
ma_liste = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
btn_choisir= Button (fenetre, text="Choisir", command= choisir)
btn_choisir.place(x=215, y=200)
txt_a=Label (fenetre, text="Tire au sort des lettres!")
txt_a.place(x=25,y=205)
txt_b=Label (fenetre, text="Vous avez choisi le jeu des lettres!!")
txt_b.place(x=170, y=15)
btn_description= Button (text= "Lisez moi!", bg="red", fg="white", command = topLevel)
btn_description.place(x=400, y=60)
fenetre.mainloop() |
Partager