From fd5448a91d8b49c039da77a648094e0ccabcbebb Mon Sep 17 00:00:00 2001 From: "bollet.c" <> Date: Sun, 24 Sep 2023 16:42:20 +0200 Subject: [PATCH] changement d'interface vers une interface en ligne de commande --- ascii/titre_accueil.txt | 0 interface.py | 64 ++++++----------------------------------- main.py | 10 +++---- 3 files changed, 14 insertions(+), 60 deletions(-) create mode 100644 ascii/titre_accueil.txt diff --git a/ascii/titre_accueil.txt b/ascii/titre_accueil.txt new file mode 100644 index 0000000..e69de29 diff --git a/interface.py b/interface.py index ff872ed..d87d02d 100644 --- a/interface.py +++ b/interface.py @@ -1,58 +1,12 @@ -from tkinter import * -from tkinter.messagebox import showinfo - - -class Accueil(Tk): - """interface graphique pour les paramètres""" - def __init__(self): - super().__init__() - - # root - self.title("Jeu de rôle") - self.geometry('500x500') - - - titre = Label(self, text="Bienvenue", font=("Arial", 42)).pack() - sous_titre = Label(self, text="Veuillez Choisir un personnage", font=("Arial", 10)).pack() - #choix du personnage - frameChoixPerso = LabelFrame(self, text="Choix du personnage", padx=20, pady=20) - frameChoixPerso.pack(fill="both", expand="yes") - - Label(frameChoixPerso, text="A l'intérieure de la frame").pack() - - - choixPerso = Listbox(frameChoixPerso) - self.listePersos = ["guerrier","magicien","voleur","elfe"] - for i in range(len(self.listePersos)): - choixPerso.insert(i, self.listePersos[i]) - - choixPerso.pack() - - - def add_label(self, txt): - Label(self, text=txt).pack() - - def add_entry(self, default): - self.entry_value = default - Entry(self, textvariable=self.entry_value, width=30).pack() - -class FenetreCombat(Tk): +class FenetreCombat(): def __init__(self, nom, texte_de_presentation): - """initialise une interface graphique pour un combat""" - self.root = App(nom) - + """initialise une interface pour un combat""" self.texte_de_presentation = texte_de_presentation - self.root.add_label("bonjour") - self.root.add_entry("sodvuhmwsoudvhmwsouvh") - - combat_btn = Button(self.root, text="Combattre", command=self.combattre) - pasCombat_btn = Button(self.root, text="Ne pas combattre", command=self.pasCombattre) - def combattre(self): - pass - def pasCombattre(self): - pass -def fenetreCombat(nom, texte_de_presentation): - root = App(nom) - root.add_label("bonjour") - root.add_entry("sodvuhmwsoudvhmwsouvh") + self.instructions() + def instructions(self): + print(texte_de_presentation) +def affiche_fichier(path): + with open(path, 'r') as file: + for line in file: + print(line) \ No newline at end of file diff --git a/main.py b/main.py index 4d53c36..fd02759 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,11 @@ def combat(perso1, perso2): perso1.change_exp(1) else: perso2.change_exp(1) -def test_main_cli(): +def main(): + accueil("Jeu de rôle") + print("Bienvenue dans...") + affiche_fichier("ascii/titre_accueil.txt") + nomJoueur1 = input("Quel est votre nom ? ") print("Vous pouvez être : \n guerrier \n magicien \n voleur \n elfe") catJoueur1 = input("Quel est votre catégorie (l'écrire en toutes lettres) ? ") @@ -30,9 +34,5 @@ def test_main_cli(): joueur2 = Personnage("ennemi", choice(["guerrier","magicien","voleur","elfe"])) combat(joueur1, joueur2) -def main(): - accueil = Accueil() - - if __name__ == "__main__": main() \ No newline at end of file