Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import random
- # Initialize the window
- window = tk.Tk()
- window.title("Dice Roll")
- window.geometry("200x300")
- # Create a label to display the dice face
- dice_label = tk.Label(window, font=("Helvetica", 100), padx=50, pady=50)
- dice_label.pack()
- # Function to roll the dice
- def roll_dice():
- dice_faces = ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
- dice_face = random.choice(dice_faces)
- dice_label.config(text=dice_face)
- # Create a button to roll the dice
- roll_button = tk.Button(window, text="Roll", command=roll_dice)
- roll_button.pack()
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement