-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (36 loc) · 1.31 KB
/
main.py
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
import tkinter as tk
from datetime import datetime
from PIL import Image, ImageTk
# Function to update the time and date
def update_time():
# Get the current time and date
current_time = datetime.now().strftime('%H:%M:%S')
current_date = datetime.now().strftime('%Y-%m-%d')
# Update the labels with the current time and date
time_label.config(text=current_time)
date_label.config(text=current_date)
# Schedule the update_time function to be called after 1000 milliseconds (1 second)
root.after(1000, update_time)
# Create the main window
root = tk.Tk()
root.title("Date and Time")
root.geometry("600x250")
image = Image.open('icon.png')
icon = ImageTk.PhotoImage(image)
# Set the icon for the window
root.iconphoto(False, icon)
# Set label
label = tk.Label(root, bg='white')
label.pack()
# Create and pack the time label
time_label = tk.Label(label, font=('Kanit', 80), fg='black', bg='white')
time_label.pack(pady=20)
# Create and pack the date label
date_label = tk.Label(label, font=('Kanit', 24), fg='black', bg='white')
date_label.pack(pady=0)
# Set the window background color
root.configure(bg='white')
# Call the update_time function to update the time initially
update_time()
# Start the main loop of the tkinter window
root.mainloop()