Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
jake158 committed May 3, 2024
1 parent 4ae4dfe commit 6013ab3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/frames/pomodoro_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
BREAK_HOVER = "#adaaaa"
RESET_BTN_COLOR = "#cca508"
RESET_HOVER = "#e3b707"
CONNECTED_TEXT = "#45b54e"
DISCONNECTED_TEXT = "#f75a4f"
CONNECTED_COLOR = "#45b54e"
DISCONNECTED_COLOR = "#f75a4f"
CONNECTED_TEXT = "Connected to Discord [click to disconnect]"
DISCONNECTED_TEXT = "Not connected to Discord [click to connect]"


class PomodoroFrame(ctk.CTkFrame):
Expand Down Expand Up @@ -49,8 +51,8 @@ def initialize_ui(self, config):
self.reset_button = ctk.CTkButton(self, text="Reset", font=("Roboto", 17), fg_color=RESET_BTN_COLOR, hover_color=RESET_HOVER, command=self.reset)
self.reset_button.pack(pady=(0, 10))

self.discord_button = ctk.CTkButton(self, text="Connected to Discord [click to disconnect]", font=("Roboto", 12),
fg_color="transparent", text_color=CONNECTED_TEXT, hover=False, width=70, command=self.toggle_rpc)
self.discord_button = ctk.CTkButton(self, text=CONNECTED_TEXT, font=("Roboto", 12),
fg_color="transparent", text_color=CONNECTED_COLOR, hover=False, width=70, command=self.toggle_rpc)
self.discord_button.pack(pady=(20, 0))

def initialize_state(self, config):
Expand Down Expand Up @@ -91,16 +93,16 @@ def toggle_rpc(self):

def connect_rpc(self):
if self.rpc.connect():
self.discord_button.configure(text="Connected to Discord [click to disconnect]", text_color=CONNECTED_TEXT, state="normal")
self.discord_button.configure(text=CONNECTED_TEXT, text_color=CONNECTED_COLOR, state="normal")
else:
self.discord_button.configure(text="Not connected to Discord [click to connect]", text_color=DISCONNECTED_TEXT, state="normal")
self.discord_button.configure(text=DISCONNECTED_TEXT, text_color=DISCONNECTED_COLOR, state="normal")
CTkMessagebox(title="Error", message="Connecting to Discord failed\nCheck console for error output", icon="cancel")

def disconnect_rpc(self):
if self.rpc.disconnect():
self.discord_button.configure(text="Not connected to Discord [click to connect]", text_color=DISCONNECTED_TEXT, state="normal")
self.discord_button.configure(text=DISCONNECTED_TEXT, text_color=DISCONNECTED_COLOR, state="normal")
else:
self.discord_button.configure(text="Connected to Discord [click to disconnect]", text_color=CONNECTED_TEXT, state="normal")
self.discord_button.configure(text=CONNECTED_TEXT, text_color=CONNECTED_COLOR, state="normal")
CTkMessagebox(title="Error", message="Disconnecting from Discord failed\nCheck console for error output", icon="cancel")

def update_rpc(self):
Expand Down

0 comments on commit 6013ab3

Please sign in to comment.