|
| 1 | +import tkinter as tk |
| 2 | +import random |
| 3 | + |
| 4 | +# List of motivational quotes |
| 5 | +quotes = [ |
| 6 | + "Life isn't about getting and having, it's about giving and being. - Kevin Kruse", |
| 7 | + "Whatever the mind of man can conceive and believe, it can achieve. - Napoleon Hill", |
| 8 | + "The only way to do great work is to love what you do. - Steve Jobs", |
| 9 | + "Strive not to be a success, but rather to be of value. - Albert Einstein", |
| 10 | + "I attribute my success to this: I never gave or took any excuse. - Florence Nightingale", |
| 11 | + "You miss 100% of the shots you don't take. - Wayne Gretzky", |
| 12 | + "Every strike brings me closer to the next home run. - Babe Ruth", |
| 13 | +] |
| 14 | + |
| 15 | +last_quote = None |
| 16 | + |
| 17 | +# Initialize main window |
| 18 | +root = tk.Tk() |
| 19 | +root.title("Motivational Quote Generator") |
| 20 | + |
| 21 | +# Set window size |
| 22 | +screen_width = root.winfo_screenwidth() |
| 23 | +screen_height = root.winfo_screenheight() |
| 24 | +root.geometry(f"{screen_width}x{screen_height}") |
| 25 | +root.configure(bg="black") # Background color |
| 26 | + |
| 27 | +# Create label to display quote |
| 28 | +quote_label = tk.Label( |
| 29 | + root, |
| 30 | + text=random.choice(quotes), |
| 31 | + font=("Helvetica", 32, "italic"), |
| 32 | + fg="white", |
| 33 | + bg="black", |
| 34 | + wraplength=int(screen_width * 0.7), |
| 35 | + justify="center" |
| 36 | +) |
| 37 | +quote_label.pack(expand=True) |
| 38 | + |
| 39 | +# Function to update quote |
| 40 | +def update_quote(): |
| 41 | + global last_quote |
| 42 | + new_quote = random.choice(quotes) |
| 43 | + while new_quote == last_quote: |
| 44 | + new_quote = random.choice(quotes) |
| 45 | + last_quote = new_quote |
| 46 | + quote_label.config(text=new_quote) |
| 47 | + root.after(5000, update_quote) # Update every 5 seconds |
| 48 | + |
| 49 | +update_quote() # Start updating |
| 50 | + |
| 51 | +root.mainloop() |
0 commit comments