ateliers:robotique:les_bases_de_tkinter
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
ateliers:robotique:les_bases_de_tkinter [2023/03/27 17:27] – [Barre de menu] 91.176.84.106 | ateliers:robotique:les_bases_de_tkinter [2024/03/25 14:02] (Version actuelle) – [traduisons :] 109.133.206.189 | ||
---|---|---|---|
Ligne 36: | Ligne 36: | ||
<code python> | <code python> | ||
- | from tkinter | + | import |
- | fenetre = Tk() | + | fenetre = tk.Tk() |
- | label = Label(fenetre, | + | label = tk.Label(fenetre, |
label.pack() | label.pack() | ||
Ligne 52: | Ligne 52: | ||
<code python> | <code python> | ||
- | from tkinter | + | import |
</ | </ | ||
- | Cela signifie que, **depuis** (from) **tkinter** | + | Cela signifie que tu importes |
Nous créons ensuite une variable nommée " | Nous créons ensuite une variable nommée " | ||
Ligne 63: | Ligne 63: | ||
<code python> | <code python> | ||
# entrée | # entrée | ||
- | value = StringVar() | + | value = StringVar() |
value.set(" | value.set(" | ||
- | entree = Entry(fenetre, | + | entree = tk.Entry(fenetre, |
entree.pack() | entree.pack() | ||
</ | </ | ||
Ligne 205: | Ligne 205: | ||
menu1.add_command(label=" | menu1.add_command(label=" | ||
menubar.add_cascade(label=" | menubar.add_cascade(label=" | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | from tkinter import * | ||
- | import time | ||
- | import tkinter.font as tkFont | ||
- | import random | ||
- | base = 10 | ||
- | random1 = random.randint(0, | ||
- | random2 = random.randint(0, | ||
- | score = 0 | ||
- | def compteur(): | ||
- | for compteur in range(60000): | ||
- | print(compteur) | ||
- | time.sleep(1) | ||
- | def fermer(): | ||
- | if score< | ||
- | print(" | ||
- | else: | ||
- | print(" | ||
- | quit() | ||
- | |||
- | def nouveau_score(): | ||
- | global score | ||
- | score += 1 | ||
- | print(" | ||
- | |||
- | fenetre = Tk() | ||
- | compteur() | ||
- | # boucle pour créer les boutons | ||
- | for ligne in range(base): | ||
- | for colonne in range(base): | ||
- | Button(fenetre, | ||
- | |||
- | |||
- | # bouton aléatoire | ||
- | Button(fenetre, | ||
- | |||
- | |||
- | fenetre.mainloop() | ||
- | |||
- | |||
ateliers/robotique/les_bases_de_tkinter.1679930823.txt.gz · Dernière modification : 2023/03/27 17:27 de 91.176.84.106