File size: 2,618 Bytes
ea1aa53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import pygame
import os
import json
import time
import random

# Initialize Pygame
pygame.init()

# Set up the window
resolution = (800, 600)
screen = pygame.display.set_mode(resolution)
pygame.display.set_caption("Calendar")

# Load the icon
icon = pygame.image.load("icon.png")
pygame.display.set_icon(icon)

# Load the background image
bg = pygame.image.load("space.jpeg")

# Set up the font
font = pygame.font.Font(None, 36)

# Get the current date and time
current_time = time.localtime()
current_date = f"{current_time.tm_mday}/{current_time.tm_mon}/{current_time.tm_year}"

# Create the text elements
welcome_text = font.render("Welcome back!", True, (255, 255, 255))
date_text = font.render(f"Today's date is: {current_date}", True, (255, 255, 255))
time_text = font.render(f"{current_time.tm_hour}:{current_time.tm_min}:{current_time.tm_sec}", True, (255, 255, 255))

# Set the positions for the text elements
welcome_pos = (10, 10)
date_pos = (10, 50)
time_pos = (10, 90)

# Load the saved events from the JSON file
try:
    with open("save.json", "r") as f:
        events = json.load(f)
except (FileNotFoundError, json.JSONDecodeError):
    # If the file is not found or is empty, create a new empty list
    events = []

# Check for events that are a week in the future
for event in events:
    event_time = time.strptime(event["date"], "%d %m %y")
    if abs(event_time.tm_yday - current_time.tm_yday) == 7:
        print(f"You have an event in a week: {event['title']} on {event['date']}")

# Check if there are any events today
today_events = [event for event in events if event["date"] == current_date]
if today_events:
    print("You have an event today!")

# Create a new event
new_event_title = input("Enter the event title: ")
new_event_date = input("Enter the event date (DD MM YY): ")
new_event_time = input("Enter the event time (HH MM SS): ")
new_event = {"title": new_event_title, "date": new_event_date, "time": new_event_time}
events.append(new_event)

# Main game loop
running = True
while running:
    # Handle events
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # Draw the background
    screen.blit(bg, (0, 0))

    # Draw the text elements
    screen.blit(welcome_text, welcome_pos)
    screen.blit(date_text, date_pos)
    screen.blit(time_text, time_pos)

    # Update the display
    pygame.display.flip()

# Save the events to the JSON file
with open("save.json", "w") as f:
    json.dump(events, f)

# Quit Pygame
pygame.quit()