Browse Source

interface graphique qui ne fonctionne pas

master
corentin.bollet 1 year ago
parent
commit
e7233c113b
  1. 46
      interface.py
  2. 8
      main.py

46
interface.py

@ -4,21 +4,39 @@ from tkinter.messagebox import showinfo
class App(tk.Tk): class App(tk.Tk):
def __init__(self): def __init__(self, nom):
super().__init__() super().__init__()
# root
self.title(nom)
self.geometry('500x500')
def add_label(self, txt):
ttk.Label(self, text=txt).pack()
def add_entry(self, default):
entry_value = default
ttk.Entry(self, textvariable=entry_value, width=30).pack()
class FenetreCombat(tk.Tk):
def __init__(self, nom, texte_de_presentation):
"""initialise une interface graphique pour un combat"""
self.root = App(nom)
self.texte_de_presentation = texte_de_presentation
self.root.add_label("bonjour")
self.root.add_entry("sodvuhmwsoudvhmwsouvh")
self.root.add_label(entry_value)
combat_btn = tk.Button(self.root, text="Combattre", command=self.combattre)
pasCombat_btn = tk.Button(self.root, text="Ne pas combattre", command=self.pasCombattre)
def combattre(self):
pass
def pasCombattre(self):
pass
app = FenetreCombat("sdf", "txt pre")
# root
self.title('Jeu de rôle')
self.geometry('500x500')
# label
self.label = ttk.Label(self, text='Bienvenue !')
self.label.pack()
# button
self.button = ttk.Button(self, text='test')
self.button['command'] = self.button_clicked
self.button.pack()
def button_clicked(self):
showinfo(title='Information', message='Bonjour !')

8
main.py

@ -30,8 +30,8 @@ def test_main_cli():
combat(joueur1, joueur2) combat(joueur1, joueur2)
def main(): def main():
acc = App() accueil = App("Jeu de rôle")
if __name__ == "__main__":
app = App()
app.mainloop()
if __name__ == "__main__":
main()
Loading…
Cancel
Save