Changeset c251a80 in flowtimer
- Timestamp:
- 08/29/24 15:21:23 (9 months ago)
- Branches:
- guix
- Children:
- 80996d0
- Parents:
- 7a52e57
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
README.md
r7a52e57 rc251a80 18 18 - Python 3.x 19 19 20 ### Test without install 21 ```bash 22 git clone --branch guix https://gitlab.kid.local:/legacy/flowtimer.git 23 cd flowtimer 24 25 guix shell python python:tk python-pillow -- 26 export PYTHONPATH=$PYTHONPATH:./ 27 python3 flowtimer/main.py 28 ``` 29 20 30 ### Installation 21 31 22 32 1. Clone the repository: 23 33 ```bash 24 git clone --branch guix https://gitlab.kid.local:/legacy/flowtimer.git25 34 git clone --branch guix https://gitlab.kid.local:/legacy/flowtimer.git 35 cd flowtimer 26 36 ``` 37 2. Install the app and required dependencies 38 ```bash 39 pip3 install . 27 40 28 2. Install the required dependencies:29 ```bash30 pip3 install .31 41 ``` 32 33 42 ### Usage 34 43 … … 101 110 2. **Run Flowtimer:** 102 111 ```bash 103 python flowtimer.py--config /path/to/config_file.json112 python3 flowtimer.py --start --config /path/to/config_file.json 104 113 ``` 105 114 … … 109 118 To change the timings or the order of phases, simply edit the JSON file and rerun the script. 110 119 111 ### Default Configuration112 113 If no configuration file is provided, Flowtimer will use the following default settings:114 115 - 25 minutes of work116 - 5 minutes of short break117 - 4 work sessions before a 15-minute long break118 120 119 121 ### Command-line Options … … 125 127 126 128 ```bash 127 python flowtimer.py --config myconfig.json129 python3 flowtimer.py --config myconfig.json 128 130 ``` 129 131 -
flowtimer/main.py
r7a52e57 rc251a80 1 1 import tkinter as tk 2 2 import tkinter.ttk as ttk 3 from tkinter import filedialog 4 from Schedule import Schedule 3 from tkinter import filedialog, messagebox 5 4 from PIL import Image, ImageTk 6 5 from pathlib import Path 7 6 import datetime 7 import argparse 8 9 from Schedule import Schedule 8 10 9 11 10 12 class TimerApp(tk.Frame): 11 13 12 def __init__(self, parent, tick speed):14 def __init__(self, parent, tick_speed, config_file, autostart): 13 15 14 16 super().__init__(parent) 15 17 self.parent = parent 16 self.tick_speed = tickspeed 17 self.count = 0 18 self.load_config() 18 self.tick_speed = tick_speed 19 19 self.photo = ImageTk.PhotoImage(file=Path(__file__).parent / 20 20 'resources' / 'flowtimer_startbg_new.png') 21 21 self.config_state = 'default' 22 print("Config:", config_file) 23 self.schedule = self.load_config(config_file) 22 24 23 25 self.build_gui() 26 if autostart: 27 self.start() 24 28 25 29 def build_gui(self): … … 170 174 def change_config(self, json_string): 171 175 self.schedule = Schedule.from_json(json_string) 176 return self.schedule 172 177 173 178 def load_config(self, file_name=Path(__file__).parent / 'configs' / 'default.json'): 174 with open(file_name) as config_file: 175 self.change_config(config_file.read()) 179 try: 180 with open(file_name) as config_file: 181 schedule = self.change_config(config_file.read()) 182 except Exception as e: 183 messagebox.showerror('Config error', f'Can not load {file_name}\n\nDefault loaded instead') 184 return Schedule.default() 185 return schedule 176 186 177 187 def select_config(self): … … 189 199 time = now.strftime("%H:%M:%S") 190 200 201 parser = argparse.ArgumentParser(description="Load specified config file and autostart if needed") 202 parser.add_argument('--start', dest='autostart', action='store_true', default=False, 203 required=False, help='use --start to autostart the timer with the given config') 204 parser.add_argument('--config', dest='config_file', required=False, default=Path(__file__).parent / 'configs' / 'default.json', 205 help='use --config /path/to/config_file.json to specify the configuration of the timer') 206 207 args = parser.parse_args() 208 191 209 root = tk.Tk() 192 210 root.title("--=> flowtimer <=-- " + " date: " + date + " time: " + time) 193 211 root.geometry("1280x860") 194 212 root.config(bg='black') 195 root.iconphoto(False, ImageTk.PhotoImage(Image.open(Path(__file__).parent / 'resources' / 'icon_bombtimer.png'))) 196 197 app = TimerApp(root, tickspeed=1) 213 root.iconphoto(False, ImageTk.PhotoImage(Image.open(Path(__file__).parent / 214 'resources' / 215 'icon_bombtimer.png'))) 216 217 app = TimerApp(root, 218 tick_speed=1, 219 config_file=args.config_file, 220 autostart=args.autostart) 198 221 199 222 app.mainloop()
Note:
See TracChangeset
for help on using the changeset viewer.