import tkinter as tk
from tkinter import ttk, messagebox
import sqlite3
import pandas as pd
import smtplib
# Database Setup
conn = sqlite3.connect("job_tracker.db")
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS jobs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
company TEXT,
role TEXT,
date_applied TEXT,
status TEXT
)
""")
conn.commit()
# GUI Application
class JobTrackerApp:
def __init__(self, root):
self.root = root
self.root.title("Job Application Tracker")
self.root.geometry("600x400")
# Labels
ttk.Label(root, text="Company:").grid(row=0, column=0)
ttk.Label(root, text="Role:").grid(row=1, column=0)
ttk.Label(root, text="Date Applied:").grid(row=2, column=0)
ttk.Label(root, text="Status:").grid(row=3, column=0)
# Entry Fields
self.company_entry = ttk.Entry(root)
self.role_entry = ttk.Entry(root)
self.date_entry = ttk.Entry(root)
self.status_combo = ttk.Combobox(root, values=["Pending", "Interview", "Rejected", "Hired"])
self.company_entry.grid(row=0, column=1)
self.role_entry.grid(row=1, column=1)
self.date_entry.grid(row=2, column=1)
self.status_combo.grid(row=3, column=1)
# Buttons
ttk.Button(root, text="Add Job", command=self.add_job).grid(row=4, column=0)
ttk.Button(root, text="Show Jobs", command=self.show_jobs).grid(row=4, column=1)
ttk.Button(root, text="Export to CSV", command=self.export_csv).grid(row=5, column=0)
ttk.Button(root, text="Send Follow-up", command=self.send_followup).grid(row=5, column=1)
def add_job(self):
company = self.company_entry.get()
role = self.role_entry.get()
date = self.date_entry.get()
status = self.status_combo.get()
if not company or not role or not date or not status:
messagebox.showerror("Error", "All fields are required!")
return
cursor.execute("INSERT INTO jobs (company, role, date_applied, status) VALUES (?, ?, ?, ?)",
(company, role, date, status))
conn.commit()
messagebox.showinfo("Success", "Job Application Added!")
def show_jobs(self):
jobs_window = tk.Toplevel(self.root)
jobs_window.title("Job Applications")
tree = ttk.Treeview(jobs_window, columns=("ID", "Company", "Role", "Date", "Status"), show="headings")
tree.heading("ID", text="ID")
tree.heading("Company", text="Company")
tree.heading("Role", text="Role")
tree.heading("Date", text="Date Applied")
tree.heading("Status", text="Status")
tree.pack(fill="both", expand=True)
cursor.execute("SELECT * FROM jobs")
for row in cursor.fetchall():
tree.insert("", "end", values=row)
def export_csv(self):
cursor.execute("SELECT * FROM jobs")
data = cursor.fetchall()
df = pd.DataFrame(data, columns=["ID", "Company", "Role", "Date Applied", "Status"])
df.to_csv("job_applications.csv", index=False)
messagebox.showinfo("Exported", "Job Applications saved as CSV!")
def send_followup(self):
email = "your-email@gmail.com" # Change to your email
password = "your-password" # Use App Password for security
cursor.execute("SELECT company, role FROM jobs WHERE status='Pending'")
pending_jobs = cursor.fetchall()
if not pending_jobs:
messagebox.showinfo("No Follow-ups", "No pending applications to follow up on.")
return
msg = "Subject: Follow-up on Job Applications\n\n"
msg += "Here are your pending job applications:\n"
for company, role in pending_jobs:
msg += f"- {role} at {company}\n"
try:
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(email, password)
server.sendmail(email, email, msg)
server.quit()
messagebox.showinfo("Email Sent", "Follow-up email sent successfully!")
except Exception as e:
messagebox.showerror("Error", f"Failed to send email: {e}")
# Run App
root = tk.Tk()
app = JobTrackerApp(root)
root.mainloop()
No comments:
Post a Comment