python-by-example-150-chall.../challenges124_132/challenge-125_.py

18 lines
366 B
Python
Raw Normal View History

2021-12-08 19:08:24 +08:00
from tkinter import *
import random
def click():
num=random.randint(1,6)
answer["text"]=num
window=Tk()
window.title("Roll a dice")
window.geometry("100x120")
button1=Button(text="Roll", command=click)
button1.place(x=30, y=30, width=50, height=25)
answer=Message(text="")
answer.place(x=40, y=70, width=30, height=25)
window.mainloop()