import tkinter as tk
def play_button_clicked():
# Define the action to be performed when the play button is clicked
print("Play button clicked!")
# Destroy all widgets
for widget in root.winfo_children():
widget.destroy()
Create the main window
root = tk.Tk()
root.title("Play Button UI")
Get the dimensions of the main window
window_width = root.winfo_screenwidth()
window_height = root.winfo_screenheight()
Set the geometry of the window
root.geometry(f"{window_width}x{window_height}")
Create a canvas to draw the textured background
canvas = tk.Canvas(root, width=window_width, height=window_height)
canvas.pack()
Create a textured background
for i in range(0, window_width, 20):
for j in range(0, window_height, 20):
if (i + j) % 40 == 0:
canvas.create_rectangle(i, j, i + 20, j + 20, fill="lightgray", outline="")
Create the title label and place it on the canvas
title_label = tk.Label(root, text="Welcome to the Game", font=("Arial", 32), bg=canvas["bg"])
canvas.create_window(window_width // 2, window_height // 4, window=title_label)
Define a custom font for the play button
play_button_font = ("Helvetica", 20, "bold")
Create the play button and place it on the canvas
play_button = tk.Button(root, text=" Play ", command=play_button_clicked, font=play_button_font)
canvas.create_window(window_width // 2, window_height // 2, window=play_button)
Run the Tkinter event loop
root.mainloop()