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/01/29 17:34] – 81.246.138.255 | 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(); | ||
+ | |||
+ | $(" | ||
+ | event.preventDefault(); | ||
+ | $subMenu.slideToggle(50); | ||
+ | $(this).find(" | ||
+ | }); | ||
+ | |||
+ | // Gestion de l' | ||
+ | $("# | ||
+ | $subMenu.slideUp(50); | ||
+ | $(" | ||
+ | }); | ||
+ | }); | ||
+ | </ | ||
+ | | ||
+ | | ||
+ | ===== CSS ===== | ||
+ | /******** SUB MENU ********/ | ||
+ | .sub-menu ul { | ||
+ | display: none; | ||
+ | position: absolute; | ||
+ | border-radius: | ||
+ | z-index: 100; | ||
+ | left: 200px; | ||
+ | } | ||
+ | |||
+ | .sub-menu li { | ||
+ | display: block; | ||
+ | padding: 10px; | ||
+ | color: #333; | ||
+ | text-decoration: | ||
+ | } | ||
+ | .sub-menu li input { | ||
+ | color: #333; | ||
+ | width: 20px; | ||
+ | height: 20px; | ||
+ | left: -35px; | ||
+ | position: absolute; | ||
+ | transform: rotate(-45deg); | ||
+ | top: 40px; | ||
+ | } | ||
+ | .sub-menu li label { | ||
+ | color: white; | ||
+ | position: absolute; | ||
+ | left: -25px; | ||
+ | font-size: 1.3rem; | ||
+ | transform: rotate(-45deg); | ||
+ | left: 33px; | ||
+ | top: -10px; | ||
+ | } | ||
+ | |||
+ | .sub-menu li:hover { | ||
+ | background-color: | ||
+ | } | ||
+ | |||
+ | / | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | 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.1706546048.txt.gz · Dernière modification : 2024/01/29 17:34 de 81.246.138.255