"MyDigitalJournal" is a Python-based digital diary application that allows users to securely record, view, and manage their personal entries using SQLite and a user-friendly GUI.
"MyDigitalJournal" is a Python-based digital diary application that allows users to securely record, view, and manage their personal entries using SQLite and a user-friendly GUI.
1. sqlite3: Interaction with SQLite database.
2. Datetime: Handling date and time-related operations.
3. tkinter: Creating the graphical user interface.
4. tkinter. message box: Displaying informative messages in the GUI.
import sqlite3 import datetime import tkinter as tk from tkinter import messagebox
-1692524759-2057.png)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
DETAILED PROCESS:
1. Registration Function for Users:
def register_user_gui():
register_window = tk.Toplevel(main)
register_window.title("Register User")
register_window.configure(bg="lightgreen")
register_window.state('zoomed')
register_frame = tk.Frame(register_window)
register_frame.pack(padx=100, pady=100)
tk.Label(register_window, text="Username:",fg="blue",font=("Times New Roman",14)).pack()
username_entry = tk.Entry(register_window)
username_entry.pack(pady=20)
tk.Label(register_window, text="Password:",fg="blue",font=("Times New Roman",14)).pack()
password_entry = tk.Entry(register_window, show="*")
password_entry.pack(pady=20)
tk.Button(register_window, text="Register", command=lambda: register_user(username_entry.get(), password_entry.get()),font=("Times New Roman",14)).pack()
def register_user(username, password):
if not username or not password:
messagebox.showerror("Error", "Please enter both username and password.")
return
cursor.execute('select id from login_users where username=?',(username,))
existed_user=cursor.fetchone()
if existed_user:
messagebox.showerror("Registration failed","already registered")
else:
cursor.execute('insert into login_users (username, password) VALUES (?,?)',(username, password))
connection.commit()
messagebox.showinfo("Success","User registered successfully!")
-1692524815-2057.png)
2. Login Function.:
def login_user_gui():
login_window = tk.Toplevel(main)
login_window.title("Log In")
login_window.configure(bg="lightgray")
login_window.state('zoomed')
login_frame = tk.Frame(login_window)
login_frame.pack(padx=50, pady=50)
tk.Label(login_window, text="Username:", fg="blue", font=("Times New Roman", 14)).pack()
username_entry = tk.Entry(login_window ,font=("Times New Roman", 14))
username_entry.pack(pady=20)
tk.Label(login_window, text="Password:",fg="blue", font=("Times New Roman", 14)).pack()
password_entry = tk.Entry(login_window, show="*", font=("Times New Roman", 14))
password_entry.pack(pady=20)
def login():
user_id = authenticate_user(username_entry.get(), password_entry.get())
username = username_entry.get()
password = password_entry.get()
if not username or not password:
messagebox.showerror("Error", "Both username and password are required.")
return
user_id = authenticate_user(username, password)
if user_id:
login_window.destroy()
main_menu_gui(user_id[0])
else:
messagebox.showerror("Authentication Failed", "Invalid username or password")
tk.Button(login_window, text="Log In", command=login,fg="green", font=("Times New Roman", 14)).pack(pady=20)
-1692524881-2057.png)
3. Function to Add an Entry:
def main_menu_gui(user_id):
main_menu_window = tk.Toplevel(main)
main_menu_window.title("Main Menu")
main_menu_window.state('zoomed')
main_menu_window.configure(bg="lightgray")
button_frame = tk.Frame(main_menu_window)
button_frame.pack(padx=50, pady=50)
tk.Button(main_menu_window, text="Add Diary Entry", command=lambda: add_entry_gui(user_id),fg="blue",font=("Times New Roman",14)).pack(padx=10,pady=10)
tk.Button(main_menu_window, text="View Diary Entries", command=lambda: view_entries_gui(user_id),fg="blue",font=("Times New Roman",14)).pack(padx=10,pady=10)
tk.Button(main_menu_window, text="Exit", command=lambda:exit(main_menu_window),fg="blue",font=("Times New Roman",14)).pack(padx=10,pady=10)
def add_entry_gui(user_id):
add_entry_window = tk.Toplevel(main)
add_entry_window.title("Add Diary Entry")
add_entry_window.state('zoomed')
entry_text = tk.Text(add_entry_window, height=25, width=100)
entry_text.pack()
def add_entry_to_db():
add_entry(user_id, entry_text.get("1.0", "end-1c"))
messagebox.showinfo("Entry Added", "Diary entry added successfully")
add_entry_window.destroy()
main_menu_gui(user_id)
def add_entry(user_id, entry_text):
entry_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
cursor.execute('insert into journal_entries (user_id, entry_text, entry_date) values (?,?,?)',(user_id,entry_text,entry_date))
connection.commit()
messagebox.showinfo("Entry Added", "Diary entry added successfully!")
tk.Button(add_entry_window, text="Add Entry", command=add_entry_to_db).pack()
-1692524921-2057.png)
4. View Entry Function:
def view_entries_gui(user_id):
view_entries_window = tk.Toplevel(main)
view_entries_window.title("View Diary Entries")
view_entries_window.state('zoomed')
text = tk.Text(view_entries_window, height=25, width=100)
text.pack()
text.insert(tk.END, "Date: Entry\n\n")
entries = get_entries(current_user_id)
cursor.execute('select * from journal_entries where user_id= ? ', (user_id,))
entries = cursor.fetchall()
for entry in entries:
text.insert(tk.END, f"{entry[3]}: {entry[2]}\n\n")
def view_entries(user_id):
cursor.execute('select * from journal_entries where user_id= ?', (user_id,))
entries = cursor.fetchall()
if entries:
entry_text = ""
for entry in entries:
entry_text += f"Date: {entry[3]}\nEntry: {entry[2]}\n\n"
view_entries_window = tk.Toplevel(main)
view_entries_window.title("View Diary Entries")
text = tk.Text(view_entries_window, height=15, width=50)
text.pack()
text.insert(tk.END, entry_text)
else:
messagebox.showinfo("No Entries", "Entered enteries not found")
def get_entries(user_id):
cursor.execute('select id, entry_text from journal_entries where user_id = ?', (user_id,))
entries = cursor.fetchall()
return entries
-1692524986-2057.png)
5. Displaying and Closing Program:
main = tk.Tk()
main.title("Digital Diary")
main.attributes("-fullscreen",True)
main.protocol("WM_DELETE_WINDOW", on_closing)
open_maximized(main)
button_frame = tk.Frame(main)
button_frame.pack(padx=50, pady=50)
connection.commit()
tk.Button(main, text="Register User", command=register_user_gui,fg="red", font=("Times New Roman", 14)).pack(padx=10,pady=10)
tk.Button(main, text="Log In", command=login_user_gui,fg="red", font=("Times New Roman", 14)).pack(padx=10,pady=10)
tk.Button(main, text="Log Out", command=lambda:[logout(),main.quit()],fg="red", font=("Times New Roman", 14)).pack(padx=10,pady=10)
main.mainloop()
connection.close()
-1692525024-2057.png)
-1692525065-2057.png)
DETAILED EXPLANATION OF CODE:
"MyDigitalJournal" is an innovative digital diary application developed using Python, SQL, and an intuitive graphical user interface (GUI). This project revolutionizes the traditional concept of diary-keeping by offering users a secure and efficient way to document their personal experiences, thoughts, and memories in a digital format.
Key Features:
User Authentication: Security is a top priority. Users must register with unique usernames and passwords before gaining access to their personal diaries. This ensures that only authorized individuals can view and manage their entries.
User-Friendly GUI: The GUI is designed for ease of use. Users can effortlessly navigate through different sections of the application, creating a seamless and intuitive experience.
Entry Creation: Users can craft entries by typing in their reflections, experiences, and ideas. The application automatically timestamps each entry with the date and time, capturing the moment's essence.
Entry Viewing: Entries are displayed in chronological order, enabling users to relive their experiences in a coherent timeline. This visual representation of their journey enhances the overall journaling experience.
Maximized Window Display: Each application section opens in a maximized window, allowing users to focus on their writing without distractions. This feature emphasizes a dedicated space for personal expression.
Secure Data Storage: The application utilizes SQLite, a reliable database management system, to store entries securely. The database structure is optimized for efficient data storage and retrieval.
User Feedback: Users receive informative messages and alerts throughout their interaction with the application. Whether it's a successful entry addition or an unsuccessful login attempt, the application provides relevant feedback.
Placeholder "?": To enhance user interaction, placeholder "?" prompts are strategically placed throughout the application. These placeholders guide users by indicating where information is required, ensuring a smooth and error-free experience.
Exit Functionality: The "Exit" button allows users to gracefully close individual windows without affecting the root window. This enables a seamless transition between different sections of the application.
Styling Consistency: The application employs a consistent font and styling across all windows. This uniform visual design enhances readability and creates a cohesive user experience.
"MyDigitalJournal" is an invaluable tool for individuals seeking a modern approach to journaling. By combining technological convenience with the cherished practice of documenting one's life journey, this project redefines the diary as a dynamic, digital companion. Users can effortlessly capture and revisit their thoughts and memories, fostering self-reflection and preserving moments for years to come. Whether it's for personal growth, creative expression, or simply recording life's events, "MyDigitalJournal" offers a versatile and user-centric platform for an engaging and meaningful journaling experience.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQLite CONNECTIVITY:
-1692524759-2057.png)
-1692525098-2057.png)
-1692525127-2057.png)
------------------------------------------------------------------------------------------------------------------------------------------------------------
OUTPUT:
-1691670295-2057.png)
-1691670317-2057.png)
-1691670334-2057.png)
-1691670352-2057.png)
-1691670395-2057.png)
-1691670449-2057.png)
-1691670476-2057.png)
-1691670505-2057.png)
Submitted by Bokkasam Eswarsai (Eswarsai26)
Download packets of source code on Coders Packet
Comments