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 [2023/04/03 17:35] – 91.176.84.106 | 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 de Tom | ||
+ | |||
+ | import random | ||
+ | |||
+ | def choisir_mot(): | ||
+ | mots = [" | ||
+ | return random.choice(mots) | ||
+ | |||
+ | |||
+ | def afficher_mot(mot, | ||
+ | affichage = "" | ||
+ | for lettre in mot: | ||
+ | if lettre in lettres_trouvees: | ||
+ | affichage += lettre | ||
+ | else: | ||
+ | affichage += " | ||
+ | return affichage | ||
+ | |||
+ | def pendu(): | ||
+ | mot_a_deviner = choisir_mot() | ||
+ | |||
+ | #creation du TABLEAU appele lettre trouvees | ||
+ | lettres_trouvees =[] | ||
+ | |||
+ | tentatives_max = 6 | ||
+ | tentatives = 0 | ||
+ | |||
+ | print(" | ||
+ | |||
+ | # while = tant que... | ||
+ | while tentatives <= tentatives_max: | ||
+ | lettre_choisie = input(" | ||
+ | |||
+ | if lettre_choisie in lettres_trouvees : | ||
+ | print ("tu as deja tape cette lettre gros noob. reesaie sal noob." | ||
+ | continue | ||
+ | |||
+ | if lettre_choisie in mot_a_deviner: | ||
+ | lettres_trouvees.append(lettre_choisie) | ||
+ | mot_actuel = afficher_mot(mot_a_deviner, | ||
+ | print(mot_actuel) | ||
+ | |||
+ | if " | ||
+ | print(" | ||
+ | break | ||
+ | |||
+ | else: | ||
+ | tentatives += 1 | ||
+ | print(" | ||
+ | |||
+ | if tentatives == tentatives_max: | ||
+ | print(" | ||
+ | pendu() | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | <code python> | ||
+ | # Importer le module random | ||
+ | import random | ||
+ | |||
+ | # 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 | ||
+ | def pendu(): | ||
+ | # Choisir un mot aléatoire | ||
+ | mot_a_deviner = choisir_mot() | ||
+ | |||
+ | # Initialiser les variables de jeu | ||
+ | lettres_trouvees = [] | ||
+ | tentatives_max = 6 | ||
+ | tentatives = 0 | ||
+ | |||
+ | # Afficher un message de bienvenue | ||
+ | print(" | ||
+ | |||
+ | # Boucle principale du jeu | ||
+ | while tentatives < tentatives_max: | ||
+ | # Demander à l' | ||
+ | lettre_choisie = input(" | ||
+ | |||
+ | # Vérifier si la lettre a déjà été devinée | ||
+ | if lettre_choisie in lettres_trouvees: | ||
+ | print(" | ||
+ | continue | ||
+ | |||
+ | # Vérifier si la lettre est dans le mot à deviner | ||
+ | if lettre_choisie in mot_a_deviner: | ||
+ | lettres_trouvees.append(lettre_choisie) | ||
+ | mot_actuel = afficher_mot(mot_a_deviner, | ||
+ | print(mot_actuel) | ||
+ | |||
+ | # Vérifier si le mot a été entièrement deviné | ||
+ | if " | ||
+ | print(" | ||
+ | break | ||
+ | else: | ||
+ | tentatives += 1 | ||
+ | print(" | ||
+ | |||
+ | # Afficher un message de fin de jeu | ||
+ | if tentatives == tentatives_max: | ||
+ | print(" | ||
+ | |||
+ | # Appeler la fonction pendu pour jouer au jeu | ||
+ | pendu() | ||
+ | </ | ||
<code python> | <code python> | ||
Ligne 171: | Ligne 447: | ||
(moi GPT) | (moi GPT) | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== THE LAST ONE ===== | ||
+ | <code python> | ||
+ | |||
+ | |||
+ | ######################################### | ||
+ | # - #Effacer le btn une fois cliqué | ||
+ | # - #Donner un indice après un certain score | ||
+ | # - #Ajouter un compteur de temps | ||
+ | # | ||
+ | # | ||
+ | |||
+ | from tkinter import * | ||
+ | from tkinter.ttk import * | ||
+ | import random | ||
+ | import time | ||
+ | |||
+ | fenetre = Tk() | ||
+ | fenetre.title(" | ||
+ | # | ||
+ | |||
+ | photo = PhotoImage(file=r" | ||
+ | photoimage = photo.subsample(3, | ||
+ | |||
+ | rnd_x = random.randint(0, | ||
+ | rnd_y = random.randint(0, | ||
+ | |||
+ | # On initialise la variable de score à 0 | ||
+ | compteur = 0 | ||
+ | |||
+ | def retirer_bouton(ligne, | ||
+ | global compteur | ||
+ | compteur += 1 | ||
+ | score_label.config(text=" | ||
+ | widgets = fenetre.grid_slaves(row=ligne, | ||
+ | for widget in widgets: | ||
+ | widget.grid_remove() | ||
+ | |||
+ | # On crée le bouton en position aléatoire | ||
+ | def placer_bouton_aleatoire(): | ||
+ | Button(fenetre, | ||
+ | placer_bouton_aleatoire() | ||
+ | |||
+ | def fenetre_score(): | ||
+ | global compteur | ||
+ | score_label = Label(fenetre, | ||
+ | score_label = Label(fenetre, | ||
+ | score_label.grid(row=10, | ||
+ | |||
+ | def compteur_temps(): | ||
+ | i=0 | ||
+ | while i <= 60: | ||
+ | i += 1 | ||
+ | print(i) | ||
+ | time.sleep(1) | ||
+ | break | ||
+ | while i <= 60: | ||
+ | i += 1 | ||
+ | print(i) | ||
+ | time.sleep(1) | ||
+ | # On défini la fonction appelée à chaque clic sur le bouton | ||
+ | def incrementer_compteur(): | ||
+ | # Permet d' | ||
+ | global compteur | ||
+ | compteur += 1 | ||
+ | print(" | ||
+ | |||
+ | |||
+ | # On défini la fonction appelée lorsque la fenêtre score se ferme | ||
+ | def fermer_fenetre(): | ||
+ | # fenetre_score.destroy() | ||
+ | if compteur >= 20: | ||
+ | print(" | ||
+ | |||
+ | else: | ||
+ | print(" | ||
+ | quit() | ||
+ | |||
+ | |||
+ | ############## | ||
+ | for ligne in range(10): | ||
+ | for colonne in range(10): | ||
+ | Button(fenetre, | ||
+ | |||
+ | score_label = Label(fenetre, | ||
+ | |||
+ | score_label.grid(row=0, | ||
+ | |||
+ | # fenetre.mainloop() | ||
+ | mainloop() | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | <code python> | ||
+ | from tkinter import * | ||
+ | from tkinter.ttk import * | ||
+ | import random | ||
+ | import time | ||
+ | rand = 15 | ||
+ | # On déclare nos variables pour les position en X et Y | ||
+ | rnd_x = random.randint(0, | ||
+ | rnd_Y = random.randint(0, | ||
+ | # On initialise la variable de score à 0 | ||
+ | compteur = 0 | ||
+ | |||
+ | |||
+ | def compteur_temps(): | ||
+ | i=0 | ||
+ | while i <= 60: | ||
+ | i += 1 | ||
+ | print(i) | ||
+ | time.sleep(1) | ||
+ | break | ||
+ | while i <= 60: | ||
+ | i += 1 | ||
+ | print(i) | ||
+ | time.sleep(1) | ||
+ | # On défini la fonction appelée à chaque clic sur le bouton | ||
+ | def incrementer_compteur(): | ||
+ | # Permet d' | ||
+ | global compteur | ||
+ | compteur += 1 | ||
+ | print(" | ||
+ | |||
+ | if compteur == 4: | ||
+ | print(" | ||
+ | |||
+ | |||
+ | # On défini la fonction appelée lorsque la fenêtre score se ferme | ||
+ | def fermer_fenetre(): | ||
+ | # fenetre_score.destroy() | ||
+ | if compteur >= 15: | ||
+ | print(" | ||
+ | else: | ||
+ | print(" | ||
+ | quit() | ||
+ | |||
+ | |||
+ | ############## | ||
+ | fenetre = Tk() | ||
+ | fenetre.title(" | ||
+ | # | ||
+ | |||
+ | photo = PhotoImage(file=r" | ||
+ | photoimage = photo.subsample(3, | ||
+ | |||
+ | for ligne in range(rand): | ||
+ | for colonne in range(rand): | ||
+ | Button(fenetre, | ||
+ | # On crée le bouton en position aléatoire | ||
+ | Button(fenetre, | ||
+ | |||
+ | |||
+ | def fenetre_score(): | ||
+ | global compteur | ||
+ | # On crée une nouvelle fenêtre | ||
+ | fenetre_score = Toplevel(fenetre) | ||
+ | fenetre_score.title(" | ||
+ | |||
+ | # On ajoute un label pour afficher le score | ||
+ | label_score = Label(fenetre_score, | ||
+ | label_score.pack(padx=10, | ||
+ | |||
+ | # On ajoute un bouton pour fermer la fenêtre | ||
+ | bouton_fermer = Button(fenetre_score, | ||
+ | bouton_fermer.pack(pady=10) | ||
+ | |||
+ | |||
+ | # fenetre.mainloop() | ||
+ | mainloop() | ||
+ | |||
</ | </ |
ateliers/robotique/echange_de_code.1680536133.txt.gz · Dernière modification : 2023/04/03 17:35 de 91.176.84.106