-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice.py
More file actions
27 lines (20 loc) · 770 Bytes
/
Copy pathdice.py
File metadata and controls
27 lines (20 loc) · 770 Bytes
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
import random2
import tkinter
from PIL import ImageTk, Image
root = tkinter.Tk()
root.geometry('300x300')
root.title('Rolling Dice')
heading = tkinter.Label(root,text="The dice rolls to...", fg="red", bg="pink", font = "Arial 16 bold italic")
heading.pack()
dice = ['die1.png','die2.png','die3.png','die4.png','die5.png','die6.png']
diceim=ImageTk.PhotoImage(Image.open(random2.choice(dice)))
imlabel = tkinter.Label(root, image=diceim)
imlabel.image = diceim
imlabel.pack(expand=True)
def rolling():
diceim=ImageTk.PhotoImage(Image.open(random2.choice(dice)))
imlabel.configure(image=diceim)
imlabel.image = diceim
button = tkinter.Button(root, text="Roll the Dice", command=rolling)
button.pack(expand=True)
root.mainloop()