-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
77 lines (53 loc) · 2.11 KB
/
main.py
File metadata and controls
77 lines (53 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from tkinter import *
import random
def desktop_choice():
choix = random.randint(1, 3)
if choix == 1:
result = "pierre"
elif choix == 2:
result = "ciseau"
else:
result = "fueille"
print("Ordinateur a choisis :", result)
return result
def gagnant(joueur, pc):
if joueur == pc:
return "égalité "
if (joueur == "pierre" and pc == "ciseau") or \
(joueur == "ciseau" and pc == "fueille") or \
(joueur == "fueille" and pc == "pierre"):
return "Tu a gagnez"
return "Le pc a gagner !"
def choisir(coup):
pc = desktop_choice()
pc_choice_label.config(text="Ordinateur : " + pc)
result_label.config(text=f"Toi: {coup} | Ordi: {pc}")
gagnant_label.config(text=gagnant(coup, pc))
window = Tk()
window.title("Salut")
window.geometry("720x480")
window.iconbitmap("image.ico")
window.config(background="#41B77F")
# Je cree la frame pour les bouton
right_frams = Frame(window, bg="#41B77F")
# On crée un title
window_title = Label(text="Choisis Pierre ou fueille ou ciseau", font=("Arial", 20), height=5, background="#41B77F")
window_title.pack()
# on Affiche le choix du pc
pc_choice_label = Label(window, text="Ordinateur : ?", font=("Arial", 15), bg="#41B77F")
pc_choice_label.pack()
# on affiche le resultas
result_label = Label(window, text="", font=("Arial", 16), bg="#41B77F")
result_label.pack(pady=10)
# On affiche le gagnant
gagnant_label = Label(window, text="", font=("Arial", 16), bg="#41B77F")
gagnant_label.pack(pady=10)
# Ici on va crée nos boutons
pierre_button = Button(right_frams, text="Pierre", font=("arial", 10), command=lambda: choisir("pierre"))
pierre_button.pack(side=LEFT, padx=10)
ciseau_button = Button(right_frams, text="Ciseau", font=("arial", 10), command=lambda: choisir("ciseau"))
ciseau_button.pack(side=LEFT, padx=10)
fueille_button = Button(right_frams, text="Fueille", font=("arial", 10), command=lambda: choisir("fueille"))
fueille_button.pack(side=LEFT, padx=10)
right_frams.pack(expand=TRUE)
window.mainloop()