MYM-A MODO DADO
import tkinter as tk
import threading
import time
import random
# Function to start the loading animation and display the dice result
def roll_dice():
def loading_animation():
loading_text = ["", ".", "..", "..."]
for _ in range(3):
for text in loading_text:
display_var.set(text)
time.sleep(0.5)
# Run the loading animation
loading_animation()
# Display the dice result
dice_result = random.randint(1, 3)
display_var.set(dice_result)
# Function to handle button click event
def on_button_click():
display_var.set("") # Clear display
threading.Thread(target=roll_dice).start()
# Initialize the main window
root = tk.Tk()
root.title("3 FACE DICE")
root.geometry("300x200")
# Create the UI elements
title_label = tk.Label(root, text="3 FACE DICE", font=("Helvetica", 16))
title_label.pack(pady=10)
display_var = tk.StringVar()
display_label = tk.Label(root, textvariable=display_var, font=("Helvetica", 24), width=5, height=2, relief="solid")
display_label.pack(pady=20)
click_button = tk.Button(root, text="Click", font=("Helvetica", 14), command=on_button_click)
click_button.pack(pady=10)
# Start the Tkinter event loop
root.mainloop()
No comments:
Post a Comment