The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a Python-based journaling app

Here is a complete Python-based journaling app using a simple file-based system and a Tkinter GUI interface for usability. This app allows users to create, view, and search journal entries by date or keywords.

python
import os import tkinter as tk from tkinter import messagebox, filedialog, simpledialog from datetime import datetime # Directory where journal entries are stored JOURNAL_DIR = "journal_entries" if not os.path.exists(JOURNAL_DIR): os.makedirs(JOURNAL_DIR) def save_entry(): date_str = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") filename = os.path.join(JOURNAL_DIR, f"{date_str}.txt") content = text_entry.get("1.0", tk.END).strip() if not content: messagebox.showwarning("Empty Entry", "Journal entry is empty.") return with open(filename, "w", encoding="utf-8") as f: f.write(content) messagebox.showinfo("Saved", f"Journal saved as {filename}") text_entry.delete("1.0", tk.END) def load_entry(): file_path = filedialog.askopenfilename(initialdir=JOURNAL_DIR, title="Select Entry", filetypes=(("Text Files", "*.txt"), ("All Files", "*.*"))) if file_path: with open(file_path, "r", encoding="utf-8") as f: content = f.read() text_entry.delete("1.0", tk.END) text_entry.insert(tk.END, content) def search_entries(): keyword = simpledialog.askstring("Search", "Enter keyword to search:") if not keyword: return results = [] for filename in os.listdir(JOURNAL_DIR): path = os.path.join(JOURNAL_DIR, filename) with open(path, "r", encoding="utf-8") as f: content = f.read() if keyword.lower() in content.lower(): results.append(filename) if results: result_str = "n".join(results) messagebox.showinfo("Search Results", f"Entries containing '{keyword}':n{result_str}") else: messagebox.showinfo("Search Results", f"No entries found containing '{keyword}'.") def list_all_entries(): entries = os.listdir(JOURNAL_DIR) if entries: entry_list = "n".join(sorted(entries)) messagebox.showinfo("All Entries", entry_list) else: messagebox.showinfo("All Entries", "No journal entries found.") # GUI setup root = tk.Tk() root.title("Python Journal App") root.geometry("600x500") frame = tk.Frame(root) frame.pack(pady=10) text_entry = tk.Text(frame, height=20, width=70, wrap=tk.WORD) text_entry.pack() button_frame = tk.Frame(root) button_frame.pack(pady=10) tk.Button(button_frame, text="Save Entry", command=save_entry, width=15).grid(row=0, column=0, padx=5) tk.Button(button_frame, text="Load Entry", command=load_entry, width=15).grid(row=0, column=1, padx=5) tk.Button(button_frame, text="Search Entries", command=search_entries, width=15).grid(row=0, column=2, padx=5) tk.Button(button_frame, text="List All Entries", command=list_all_entries, width=15).grid(row=0, column=3, padx=5) root.mainloop()

Features:

  • Save Entry: Stores a timestamped text file.

  • Load Entry: Loads existing entries.

  • Search Entries: Finds entries containing keywords.

  • List All Entries: Displays all saved entries.

Requirements:

  • Python 3.x

  • No external packages—standard library only.

You can expand it further with:

  • Tagging or mood tracking

  • Cloud backup

  • Markdown support

  • Password protection

Let me know if you want a terminal-only version or database integration.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About