From edb67f7d899392c68c989305f213fa58a7bad27d Mon Sep 17 00:00:00 2001 From: freeram Date: Mon, 4 Mar 2024 22:41:32 -0700 Subject: [PATCH] Add TabView, main, settings tabs --- main.py | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/main.py b/main.py index b54b6aa..12ddb67 100644 --- a/main.py +++ b/main.py @@ -1,28 +1,39 @@ import customtkinter as ctk -MAIN_RED = "#eb4034" -RED_HOVER = "#f75a4f" ctk.set_appearance_mode("dark") -ctk.set_default_color_theme("blue") +ctk.set_default_color_theme("themes/Default.json") class PomodoroFrame(ctk.CTkFrame): - def __init__(self, master, start_func): + def __init__(self, master): super().__init__(master) - # Placeholder - self.timer_display = ctk.CTkLabel(self, text="00:25:00", font=("Helvetica", 48)) + self.timer_display = ctk.CTkLabel(self, text="25:00", font=("Helvetica", 58)) self.timer_display.pack(pady=50) - self.start_button = ctk.CTkButton(self, text="Start", fg_color="transparent", border_color=MAIN_RED, - border_width=2, corner_radius=32, hover_color=RED_HOVER, command=start_func) + self.start_button = ctk.CTkButton(self, text="Start", fg_color="transparent", + border_width=2, corner_radius=32, command=self.start_timer) self.start_button.pack() + def start_timer(self): + print("Timer started") + + +class TabView(ctk.CTkTabview): + def __init__(self, master, **kwargs): + super().__init__(master, **kwargs) + + self.add("Main") + self.add("Settings") + + self.main_frame = PomodoroFrame(self.tab("Main")) + self.main_frame.pack() + class PomodoroApp(ctk.CTk): - WIDTH = 400 - HEIGHT = 400 + WIDTH = 350 + HEIGHT = 350 def __init__(self): super().__init__() @@ -30,17 +41,8 @@ def __init__(self): self.title("Pomodoro Tracker") self.geometry(f"{PomodoroApp.WIDTH}x{PomodoroApp.HEIGHT}") - tabview = ctk.CTkTabview(master=self) - tabview.pack(padx=20, pady=20) - - tabview.add("Main") - tabview.add("Settings") - - self.main_frame = PomodoroFrame(tabview.tab("Main"), self.start_timer) - self.main_frame.pack() - - def start_timer(self): - print("Timer started") + self.tabview = TabView(master=self) + self.tabview.pack(pady=30) if __name__ == "__main__":