main.py
import tkinter as tk
from timer import start_pomodoro
from breathing import start_breathing
from prompts import get_prompt
window = tk.Tk()
window.title("🧠 Mindfulness & Focus Timer")
window.geometry("400x300")
label = tk.Label(window, text="Welcome to Focus Time!", font=("Helvetica", 16))
label.pack(pady=10)
tk.Button(window, text="Start Pomodoro", command=start_pomodoro).pack(pady=10)
tk.Button(window, text="Breathing Exercise", command=start_breathing).pack(pady=10)
tk.Button(window, text="Get Mindfulness Prompt", command=lambda: label.config(text=get_prompt())).pack(pady=10)
window.mainloop()
timer.py
import time
import pygame
import threading
def play_sound():
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load("sounds/ding.wav")
pygame.mixer.music.play()
def start_pomodoro():
def run():
print("Focus time started!")
for i in range(25 * 60, 0, -1):
mins, secs = divmod(i, 60)
print(f"{mins:02d}:{secs:02d}", end='\r')
time.sleep(1)
play_sound()
print("\nTime for a break!")
threading.Thread(target=run).start()
breathing.py
import time
import threading
def start_breathing():
def run():
print("Follow the breathing pattern:")
for _ in range(4):
print("Inhale... 🫁")
time.sleep(4)
print("Hold... ✋")
time.sleep(4)
print("Exhale... 😮💨")
time.sleep(4)
threading.Thread(target=run).start()
prompts.py
import random
prompts = [
"Breathe in clarity, breathe out stress.",
"Focus on one thing at a time.",
"You are in control of your day.",
"Be here now. 🌱",
"Let go of what you can't control."
]
def get_prompt():
return random.choice(prompts)
No comments:
Post a Comment