-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (27 loc) · 1.29 KB
/
main.py
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
from tkinter import *
from random import randint
#---------------------------------------------------------------------------------
root=Tk()
root.title("Heads or Tails")
root.geometry("700x500")
root.config(bg="white")
#---------------------------------------------------------------------------------
home=PhotoImage(file='images/home.png')
head=PhotoImage(file='images/head.png')
tail=PhotoImage(file='images/tail.png')
#---------------------------------------------------------------------------------
image_label=Label(root, image=home)
image_label.pack(padx=10, pady=10)
#---------------------------------------------------------------------------------
choice_list=[head,tail]
toss_choice=randint(0,1)
#---------------------------------------------------------------------------------
def toss():
toss_choice=randint(0,1)
image_label.config(image=choice_list[toss_choice],bd=0)
#---------------------------------------------------------------------------------
toss_button=Button(root, font=('showcard gothic',15 ,'bold'),bg='#52B4F9',
width=20, height=20,text="Toss!", bd=4, command=toss)
toss_button.pack(padx=10, pady=10)
#---------------------------------------------------------------------------------
root.mainloop()