ateliers:robotique:echange_de_code
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:echange_de_code [2024/03/25 18:13] – 109.133.206.189 | ateliers:robotique:echange_de_code [2025/02/17 18:49] (Version actuelle) – portouverte | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Ici on échange nos microdes ====== | ====== Ici on échange nos microdes ====== | ||
+ | < | ||
+ | < | ||
+ | $(document).ready(function() { | ||
+ | const $subMenu = $(' | ||
+ | $subMenu.hide(); | ||
- | <code html> | + | $(" |
- | .active ul li:nth-child(1){ | + | event.preventDefault(); |
- | | + | $subMenu.slideToggle(50); |
- | | + | $(this).find(" |
- | | + | }); |
+ | |||
+ | // Gestion de l' | ||
+ | $("# | ||
+ | $subMenu.slideUp(50); | ||
+ | $(" | ||
+ | }); | ||
+ | }); | ||
+ | | ||
+ | |||
+ | |||
+ | ===== CSS ===== | ||
+ | /******** SUB MENU ********/ | ||
+ | .sub-menu ul { | ||
+ | display: none; | ||
+ | | ||
+ | border-radius: 5px; | ||
+ | | ||
+ | left: 200px; | ||
} | } | ||
- | .active ul li:nth-child(2){ | + | |
- | | + | .sub-menu li { |
- | | + | |
- | | + | |
+ | | ||
+ | text-decoration: none; | ||
} | } | ||
- | .active ul li:nth-child(3){ | + | .sub-menu li input { |
- | | + | |
- | left: 100%; | + | width: 20px; |
- | | + | height: 20px; |
+ | left: -35px; | ||
+ | | ||
+ | transform: rotate(-45deg); | ||
+ | top: 40px; | ||
} | } | ||
- | .active ul li:nth-child(4){ | + | .sub-menu li label { |
- | | + | |
- | left: 100%; | + | position: absolute; |
- | | + | left: -25px; |
+ | | ||
+ | transform: rotate(-45deg); | ||
+ | left: 33px; | ||
+ | top: -10px; | ||
} | } | ||
- | .active ul li: | + | |
- | top: 100%; | + | .sub-menu li:hover { |
- | left: 100%; | + | |
- | transition-delay: | + | |
- | } | + | |
- | .active ul li:nth-child(6){ | + | |
- | top: 100%; | + | |
- | left: 0; | + | |
- | transition-delay: | + | |
- | } | + | |
- | .active ul li:nth-child(7){ | + | |
- | | + | |
- | left: -100%; | + | |
- | transition-delay: 1.2s; | + | |
- | } | + | |
- | .active ul li: | + | |
- | top: 0; | + | |
- | left: -100%; | + | |
- | transition-delay: | + | |
} | } | ||
+ | |||
+ | / | ||
+ | | ||
</ | </ | ||
+ | < | ||
+ | git clone https:// | ||
+ | cd interactive-ink-examples-uwp | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | <code python> | ||
+ | import random | ||
+ | import tkinter as tk | ||
+ | from tkinter import StringVar, Entry, Button, PhotoImage | ||
+ | |||
+ | |||
+ | # Définir la fonction choisir_mot qui choisit un mot aléatoire | ||
+ | def choisir_mot(): | ||
+ | mots = [" | ||
+ | return random.choice(mots) | ||
+ | |||
+ | |||
+ | # Définir la fonction afficher_mot qui affiche le mot à deviner avec les lettres trouvées | ||
+ | def afficher_mot(mot, | ||
+ | affichage = "" | ||
+ | for lettre in mot: | ||
+ | if lettre in lettres_trouvees: | ||
+ | affichage += lettre | ||
+ | else: | ||
+ | affichage += " | ||
+ | return affichage | ||
+ | |||
+ | |||
+ | # Définir la fonction pendu qui permet de jouer au jeu du pendu avec une interface graphique | ||
+ | def pendu(): | ||
+ | # Choisir un mot aléatoire | ||
+ | mot_a_deviner = choisir_mot() | ||
+ | |||
+ | # Initialiser les variables de jeu | ||
+ | lettres_trouvees = [] | ||
+ | tentatives_max = 6 | ||
+ | tentatives = 0 | ||
+ | |||
+ | # Créer une fenêtre Tkinter | ||
+ | fenetre = tk.Tk() | ||
+ | fenetre.geometry(" | ||
+ | fenetre.title(" | ||
+ | |||
+ | # Créer les éléments graphiques | ||
+ | label_mot = tk.Label(fenetre, | ||
+ | label_mot.pack() | ||
+ | |||
+ | entry_lettre = tk.Entry(fenetre) | ||
+ | entry_lettre.pack() | ||
+ | |||
+ | label_tentatives = tk.Label(fenetre, | ||
+ | label_tentatives.pack() | ||
+ | |||
+ | # Fonction pour vérifier la lettre choisie | ||
+ | def verifier_lettre(): | ||
+ | nonlocal tentatives | ||
+ | lettre_choisie = entry_lettre.get() | ||
+ | entry_lettre.delete(0, | ||
+ | |||
+ | if lettre_choisie in lettres_trouvees: | ||
+ | label_tentatives.config(text=" | ||
+ | elif lettre_choisie in mot_a_deviner: | ||
+ | lettres_trouvees.append(lettre_choisie) | ||
+ | label_mot.config(text=afficher_mot(mot_a_deviner, | ||
+ | |||
+ | if " | ||
+ | label_tentatives.config(text=" | ||
+ | else: | ||
+ | tentatives += 1 | ||
+ | label_tentatives.config(text=" | ||
+ | if tentatives == tentatives_max: | ||
+ | label_tentatives.config( | ||
+ | text=" | ||
+ | |||
+ | # Créer le bouton pour valider la lettre choisie | ||
+ | btn_valider = tk.Button(fenetre, | ||
+ | btn_valider.pack() | ||
+ | |||
+ | fenetre.mainloop() | ||
+ | # Appeler la fonction pendu pour jouer au jeu | ||
+ | pendu() | ||
+ | |||
+ | | ||
+ | </ | ||
<code python> | <code python> |
ateliers/robotique/echange_de_code.1711386810.txt.gz · Dernière modification : 2024/03/25 18:13 de 109.133.206.189