diff --git a/projects/Alarm Clock/clock.py b/projects/Alarm Clock/clock.py index 40a2fd2a5..89a5e34a5 100644 --- a/projects/Alarm Clock/clock.py +++ b/projects/Alarm Clock/clock.py @@ -6,6 +6,7 @@ top.title("Dynamic Clock") # Updated title top.resizable(0, 0) # Making the window non-resizable + # Function to determine the time of day def get_time_of_day(hour): if 5 <= hour < 12: @@ -15,6 +16,7 @@ def get_time_of_day(hour): else: return "Evening" + # Function to update the time display def update_time(): current_time = strftime("%H:%M:%S %p") @@ -25,12 +27,17 @@ def update_time(): clock_time.config(text=current_time + f"\nGood {time_of_day}!") # Dynamically change the background color based on time of day - color = "lightblue" if time_of_day == "Morning" else "lightyellow" if time_of_day == "Afternoon" else "lightcoral" + color = ( + "lightblue" + if time_of_day == "Morning" + else "lightyellow" if time_of_day == "Afternoon" else "lightcoral" + ) top.configure(background=color) # Schedule the update_time function to be called again after 1000 milliseconds (1 second) clock_time.after(1000, update_time) + # Creating a Label widget to display the time clock_time = tkinter.Label( top, diff --git a/projects/Tile Matching/tile_matching.py b/projects/Tile Matching/tile_matching.py index 5c9925add..8ea33574f 100644 --- a/projects/Tile Matching/tile_matching.py +++ b/projects/Tile Matching/tile_matching.py @@ -2,6 +2,7 @@ import random from tkinter import messagebox + class TileMatchingGame: def __init__(self, root, rows, columns): self.root = root @@ -125,6 +126,7 @@ def reset_game(self): self.root.destroy() main() + def main(): root = tk.Tk() root.title("Tile Matching Game") @@ -143,5 +145,6 @@ def main(): root.mainloop() + if __name__ == "__main__": main()