-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject-5.py
More file actions
30 lines (24 loc) · 863 Bytes
/
project-5.py
File metadata and controls
30 lines (24 loc) · 863 Bytes
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
# Project-5 : DIARY
# Codesphered01010
import tkinter as tk
from tkinter import messagebox
import time
def save_diary():
content = diary_text.get("1.0", tk.END).strip()
if content:
with open("daily_diary.txt", "a") as f:
f.write(content + "\n")
f.write("---- Entry Saved on " + time.strftime("%Y-%m-%d %H:%M:%S") + " ----\n\n")
messagebox.showinfo("Success", "Diary saved successfully!")
diary_text.delete("1.0", tk.END)
else:
messagebox.showwarning("Warning", "Diary is empty!")
root = tk.Tk()
root.title("Daily Diary")
root.geometry("400x300")
tk.Label(root, text="Write your daily notes below:").pack(pady=5)
diary_text = tk.Text(root, height=12, width=40)
diary_text.pack(pady=10)
save_button = tk.Button(root, text="Save", command=save_diary)
save_button.pack(pady=5)
root.mainloop()