forked from ndleah/python-mini-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice.py
More file actions
31 lines (22 loc) · 627 Bytes
/
dice.py
File metadata and controls
31 lines (22 loc) · 627 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
28
29
30
31
from tkinter import *
import random
def roll():
r = random.randint(1, 6)
s = str(r)
e.delete(0, END)
e.insert(0, s)
def on_enter(event):
button1.config(fg="black")
def on_leave(event):
button1.config(fg="green")
root = Tk()
root.geometry("99x117+1153+210")
label = Label(root, text="Simple Dice" ,wraplength=100)
e = Entry(root, width=5)
button1 = Button(root, text="Roll", command=roll,wraplength=100)
button1.bind("<Enter>", on_enter)
button1.bind("<Leave>", on_leave)
label.grid(row=0, sticky=N)
e.grid(row=2 ,sticky=N)
button1.grid(row=4 ,sticky=S)
root.mainloop()