-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
116 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import customtkinter as ctk | ||
from src.frames.pomodoro_frame import PomodoroFrame | ||
from src.frames.settings_frame import SettingsFrame | ||
from src.frames.stats_frame import StatsFrame | ||
|
||
|
||
class TabView(ctk.CTkTabview): | ||
def __init__(self, master, **kwargs): | ||
super().__init__(master, **kwargs) | ||
self.add("Main") | ||
self.add("Settings") | ||
self.add("Stats") | ||
|
||
self.main_frame = PomodoroFrame(self.tab("Main")) | ||
self.main_frame.pack(expand=True, fill='both') | ||
|
||
self.settings_frame = SettingsFrame(self.tab("Settings")) | ||
self.settings_frame.pack(expand=True, fill='both') | ||
|
||
self.stats_frame = StatsFrame(self.tab("Stats")) | ||
self.stats_frame.pack(expand=True, fill='both') | ||
|
||
|
||
class PomodoroApp(ctk.CTk): | ||
WIDTH = 350 | ||
HEIGHT = 400 | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.title("Pomodoro Tracker") | ||
self.geometry(f"{PomodoroApp.WIDTH}x{PomodoroApp.HEIGHT}") | ||
|
||
self.tabview = TabView(master=self) | ||
self.tabview.pack(pady=(15, 30), expand=True, fill='y') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import customtkinter as ctk | ||
|
||
|
||
class EntryFrame(ctk.CTkFrame): | ||
def __init__(self, master, text, config, config_attr, defvalue, command): | ||
super().__init__(master) | ||
|
||
self.label = ctk.CTkLabel(self, text=text) | ||
self.label.pack(pady=(10, 10), padx=(10, 10)) | ||
|
||
self.controls_frame = ctk.CTkFrame(self) | ||
self.controls_frame.pack(fill=ctk.X, expand=True, padx=10) | ||
|
||
self.entry_var = ctk.IntVar(value=config.get(config_attr, defvalue)) | ||
self.entry = ctk.CTkEntry(self.controls_frame, width=35, textvariable=self.entry_var) | ||
self.entry.pack(side=ctk.LEFT, fill=ctk.X, expand=True, padx=(0, 10)) | ||
|
||
self.set_button = ctk.CTkButton(self.controls_frame, width=120, text="Set", command=command) | ||
self.set_button.pack(side=ctk.RIGHT) | ||
|
||
def get(self): | ||
return self.entry_var.get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import customtkinter as ctk | ||
|
||
|
||
class StatisticDisplay(ctk.CTkFrame): | ||
def __init__(self, master, title, initial_value="0", title_font=18, val_font=24, **kwargs): | ||
super().__init__(master, **kwargs) | ||
self.pack(pady=(10, 15), fill="x") | ||
|
||
self.title_label = ctk.CTkLabel(self, text=title, font=("Helvetica", title_font), anchor="n") | ||
self.title_label.pack(fill="x") | ||
|
||
self.value_var = ctk.StringVar(value=initial_value) | ||
self.value_label = ctk.CTkLabel(self, textvariable=self.value_var, font=("Helvetica", val_font), anchor="center") | ||
self.value_label.pack(pady=(5, 0), fill="x") | ||
|
||
def set_value(self, value): | ||
self.value_var.set(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 13 additions & 45 deletions
58
pomodorodiscord/src/settings_frame.py → pomodorodiscord/src/frames/settings_frame.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 15 additions & 44 deletions
59
pomodorodiscord/src/stats_frame.py → pomodorodiscord/src/frames/stats_frame.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,62 @@ | ||
import customtkinter as ctk | ||
from datetime import datetime | ||
from src.components.statistic_display import StatisticDisplay | ||
from src.utils import load_data | ||
from src.graphs import graph_pomodoro_sessions, graph_hours_studied | ||
|
||
|
||
class StatisticDisplay(ctk.CTkFrame): | ||
def __init__(self, master, title, initial_value="0", title_font=18, val_font=24, **kwargs): | ||
super().__init__(master, **kwargs) | ||
self.pack(pady=(10, 15), fill="x") | ||
|
||
# Title Label | ||
self.title_label = ctk.CTkLabel(self, text=title, font=("Helvetica", title_font), anchor="n") | ||
self.title_label.pack(fill="x") | ||
|
||
# Value Label | ||
self.value_var = ctk.StringVar(value=initial_value) | ||
self.value_label = ctk.CTkLabel(self, textvariable=self.value_var, font=("Helvetica", val_font), anchor="center") | ||
self.value_label.pack(pady=(5, 0), fill="x") | ||
|
||
def set_value(self, value): | ||
self.value_var.set(value) | ||
from src.logic.graphs import graph_pomodoro_sessions, graph_hours_studied | ||
|
||
|
||
class StatsFrame(ctk.CTkScrollableFrame): | ||
def __init__(self, master): | ||
super().__init__(master) | ||
|
||
# Time Studied Today | ||
|
||
self.time_today = StatisticDisplay(self, "Time Studied Today:") | ||
|
||
# Pomodoros Today | ||
self.pomodoros_today = StatisticDisplay(self, "Pomodoros Today:") | ||
|
||
# Total Hours Studied | ||
self.total_hours = StatisticDisplay(self, "Total Time Studied:") | ||
|
||
# Total Pomodoros | ||
self.total_pomodoros = StatisticDisplay(self, "Total Pomodoros:") | ||
|
||
# Update Button | ||
|
||
self.update_stats = ctk.CTkButton(self, text="Update", width=90, font=("Roboto", 16), command=self.load_stats) | ||
self.update_stats.pack(pady=(10, 0)) | ||
|
||
# Graphs | ||
|
||
self.graph_label_1 = ctk.CTkLabel(self, text="Pomodoro Sessions Graph", font=("Helvetica", 18)) | ||
self.graph_label_1.pack(pady=(32, 8)) | ||
self.graph_button_1 = ctk.CTkButton(self, text="Show", width=90, font=("Roboto", 16), command=self.show_sessions_graph) | ||
self.graph_button_1.pack() | ||
|
||
self.graph_label_2 = ctk.CTkLabel(self, text="Hours Studied Graph", font=("Helvetica", 18)) | ||
self.graph_label_2.pack(pady=(20, 8)) | ||
self.graph_button_2 = ctk.CTkButton(self, text="Show", width=90, font=("Roboto", 16), command=self.show_hours_graph) | ||
self.graph_button_2.pack() | ||
|
||
self.load_stats() | ||
|
||
def load_stats(self): | ||
data = load_data() | ||
if not data: | ||
return | ||
|
||
current_date = datetime.now().strftime("%Y-%m-%d") | ||
total_today_seconds = data.get('seconds_by_date', {}).get(current_date, 0) | ||
|
||
total_today_hours = total_today_seconds / 3600 | ||
|
||
if total_today_hours < 1: | ||
self.time_today.set_value(f"{total_today_seconds // 60} minute{'s' if total_today_seconds // 60 != 1 else ''}") | ||
else: | ||
self.time_today.set_value(f"{total_today_hours:.1f} hours") | ||
|
||
total_today_pomodoros = data.get('sessions_by_date', {}).get(current_date, 0) | ||
self.pomodoros_today.set_value(f"{total_today_pomodoros} session{'s' if total_today_pomodoros != 1 else ''}") | ||
|
||
total_seconds = data.get('total_seconds_studed', 0) | ||
total_seconds = data.get('total_seconds_studied', 0) | ||
total_hours = data.get('total_seconds_studied', 0) / 3600 | ||
|
||
if total_hours < 1: | ||
self.total_hours.set_value(f"{total_seconds // 60} minute{'s' if total_seconds // 60 != 1 else ''}") | ||
else: | ||
self.total_hours.set_value(f"{total_hours:.1f} hours") | ||
|
||
total_pomodoros = data.get('total_pomodoro_sessions', 0) | ||
self.total_pomodoros.set_value(f"{total_pomodoros} session{'s' if total_pomodoros != 1 else ''}") | ||
|
||
def show_sessions_graph(self): | ||
graph_pomodoro_sessions(load_data()) | ||
|
||
def show_hours_graph(self): | ||
graph_hours_studied(load_data()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.