Skip to content

Commit

Permalink
First release of EyesGuard for Windows written in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Vorobjev authored and Dmitry Vorobjev committed Apr 2, 2024
1 parent cdf59df commit f4d363f
Show file tree
Hide file tree
Showing 36 changed files with 1,706 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.vscode
venv
__pycache__
venv
tmp
settings.json
.*
output
logs
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## v2.0.0 - 2024-04-02
- First release of EyesGuard for Windows written in Python
22 changes: 22 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## About EyesGuard
Program EyesGuard helps you to keep vision in order.
It reminds about necessity to have a break during long work and informs about the start and the end of the break.

EyesGuard is distributed under GPL v3 licence. By for now it is tested with Python 3.11 and Windows 10.

You can find more info about EyesGuard at [www.eyesguard.ru](https://eyesguard.ru).

Command to start app while developing:
```
python ./src/main.py
```

Command for running tests:
```
python -X utf8 -m pytest .\tests\
```

Command for building .exe:
```
auto-py-to-exe
```
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
customtkinter==5.2.0
loguru==0.7.2
pydantic==2.1.1
pystray==0.19.4
pytest==7.4.0
Empty file added res/__init__.py
Empty file.
Binary file added res/img/break_wnd_bg1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/check_mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/eyes_protection_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/eyes_with_protection.ico
Binary file not shown.
Binary file added res/img/eyes_with_protection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/eyes_without_protection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from threading import Thread

from logger import logger
from model import Model
from settings import UserSettingsData
from states import StepType


class Controller:
"""Class for time and break control"""

def __init__(self):
logger.trace("Controller: object was created")

def set_model(self, model: Model):
"""Assigning model to controller"""
logger.trace("Controller: set_model")
self.model = model
self.thread_alg = None

def start(self):
"""Start controller in separated thread"""
if self.thread_alg is None:
self.thread_alg = Thread(target=self.main_loop)
self.thread_alg.start()

def stop(self):
pass

def main_loop(self):
"""Controller main loop in separated thread"""

logger.trace("Controller: main_loop")
while True:
self.model.do_current_step_actions()
self.model.wait_for_current_step_is_ended()
self.model.set_new_step_in_sequence()

def apply_view_user_settings(self, user_settings: UserSettingsData) -> None:
logger.trace("EGModel: apply_view_user_settings")
self.model.apply_new_user_settings(user_settings)

def switch_suspended_state(self):
self.model.switch_suspended_state()

def set_step(self, new_step_type: StepType):
logger.trace("Controller: set_step")
self.model.set_step(new_step_type)
29 changes: 29 additions & 0 deletions src/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from pathlib import Path as __Path

import loguru as __loguru

__LOG_LEVEL_DEBUG = "DEBUG"
__LOG_LEVEL_TRACE = "TRACE"
__LOG_LEVEL_WARNING = "WARNING"
__LOG_FORMAT = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | {file}:{line}: <level><b>{message}</b></level>"

__LOG_FILE = "./logs/log.log"

log_file_path = __Path(__LOG_FILE)
if log_file_path.exists():
log_file_path.unlink(missing_ok=True)

logger = __loguru.logger

logger.add(
sink=__LOG_FILE,
level=__LOG_LEVEL_WARNING,
format=__LOG_FORMAT,
colorize=False,
backtrace=True,
diagnose=True,
encoding="utf8",
)


logger.debug("Logging started!")
28 changes: 28 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from controller import Controller
from logger import logger
from model import Model
from view import View


def main():
"""Main function"""

logger.trace(f"Function started")

controller = Controller()
model = Model()
view = View()

controller.set_model(model=model)
model.set_view(view=view)
view.set_controller(controller=controller)

controller.start()
logger.info("Program EyesGuard started!")

view.mainloop()


# application entry point
if __name__ == "__main__":
main()
Loading

0 comments on commit f4d363f

Please sign in to comment.