Skip to content

Commit

Permalink
Restructure 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jake158 committed Apr 7, 2024
1 parent a10bdb0 commit 51b37df
Show file tree
Hide file tree
Showing 24 changed files with 24 additions and 17 deletions.
11 changes: 8 additions & 3 deletions pomodorodiscord/run.py → main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import customtkinter as ctk
from src.app import PomodoroApp
from src.utils import load_config
from src.utils import load_config, THEMES_DIR

if __name__ == "__main__":

def main():
config = load_config()
ctk.set_default_color_theme(f"themes/{config['theme']}.json")
ctk.set_default_color_theme(f"{THEMES_DIR}/{config['theme']}.json")
ctk.set_appearance_mode("dark")
app = PomodoroApp()
app.mainloop()


if __name__ == "__main__":
main()
Empty file removed pomodorodiscord/src/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
21 changes: 12 additions & 9 deletions pomodorodiscord/README.md → src/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
## Running

`python3 run.py`
`python3 main.py`

## Testing

`python3 -m unittest discover tests`

## Structure

- `run.py`: The main entry point.
- `src/`: The main package directory.
- `app.py`: Defines the main window and tab view, into which the three visible frames are packed.
- `main.py`: The main entry point.
- `src/`: Source code directory.
- `app.py`: Defines the main window and tab view, into which the three visible tabs are packed.
- `utils.py`: Loading and saving data, configuration.
- `frames/`:
- `pomodoro_frame.py`: Entire timer functionality + storing data + communicating with Rich Presence.
- `settings_frame.py`: Updates config.
- `stats_frame.py`: Displays stats and graphs.
- `reusable/`: Reusable UI components.
- `entry_frame.py`: For settings_frame.py, where you put in custom durations for the pomodoro.
- `statistic_display.py`: For stats_frame.py.
- `logic/`: Logic separate from customtkinter.
- `richpresence.py`: The Discord Rich Presence integration - editable, but if you change function args go to pomodoro_frame.py update_rpc.
- `graphs.py`: matplotlib plots using data collected.
- `sounds/`: Beep.
- `themes/`: Responsible for all colors in the GUI. Theme is loaded on launch in run.py.
- `assets/`
- `sounds/`: Beep.
- `themes/`: Responsible for all colors in the GUI. Theme is loaded on launch in run.py.
- `tests/`: Basic tests. Ignore ResourceWarnings.

## File Dependencies

- `run.py` imports and uses `src/app.py`.
- `main.py` imports and uses `src/app.py`.
- `src/app.py` imports and uses `src/frames/*` and `src/utils.py`.
- `src/frames/pomodoro_frame.py` imports and uses `src/utils.py` and `src/logic/richpresence.py`.
- `src/frames/settings_frame.py` imports and uses `src/components/entry_frame.py` and `src/utils.py`.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os
import customtkinter as ctk
from src.reusable.settings_reusable import EntryFrame
from src.utils import load_config, save_config, reload_app, beep, DEF_POMODORO_MINS, DEF_SB_MINS, DEF_LB_MINS, DEF_SB_BEFORE_L
from src.utils import THEMES_DIR, load_config, save_config, reload_app, beep, DEF_POMODORO_MINS, DEF_SB_MINS, DEF_LB_MINS, DEF_SB_BEFORE_L


class SettingsFrame(ctk.CTkScrollableFrame):
def __init__(self, master):
super().__init__(master)
self.themes_dir = 'themes'
config = load_config()

self.abcycling_var = ctk.IntVar(value=config.get("auto_break_cycling", 0))
Expand All @@ -21,7 +20,7 @@ def __init__(self, master):

self.theme_label = ctk.CTkLabel(self, text="Select Theme (RESTARTS APP):")
self.theme_label.pack(pady=(20, 0))
self.theme_options = [os.path.splitext(theme)[0] for theme in os.listdir(self.themes_dir) if theme.endswith('.json')]
self.theme_options = [os.path.splitext(theme)[0] for theme in os.listdir(THEMES_DIR) if theme.endswith('.json')]
selected = ctk.StringVar(value=config.get('theme', 'Default'))
self.theme_menu = ctk.CTkOptionMenu(self, variable=selected, values=self.theme_options, anchor="n", command=self.change_theme)
self.theme_menu.pack(pady=(10, 0))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion pomodorodiscord/src/utils.py → src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


mixer.init()
beep = mixer.Sound('sounds/beep.mp3')
beep = mixer.Sound('src/assets/sounds/beep.mp3')


DEF_POMODORO_MINS = 25
Expand All @@ -15,6 +15,7 @@

CONFIG_FILE = 'config.json'
DATA_FILE = 'data.json'
THEMES_DIR = 'src/assets/themes'


def load_file(filename, on_no_file=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class TestPomodoroFrame(unittest.TestCase):

@ignore_warnings
def setUp(self):
global root
self.config = load_config()
self.pomodoro_frame = PomodoroFrame(None)

Expand Down
File renamed without changes.

0 comments on commit 51b37df

Please sign in to comment.