-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Pcc52 #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pcc52 #796
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| from rich.console import Console | ||
| from rich.live import Live | ||
| from time import sleep | ||
| from datetime import timedelta | ||
|
|
||
|
|
||
| console = Console() | ||
|
|
||
|
|
||
| class PomodoroTimer: | ||
| def __init__(self, start_timer=25, break_timer=5): | ||
| self._timer = start_timer | ||
| self._break = break_timer | ||
| self._countdown = timedelta(minutes=self._timer) | ||
|
|
||
| def run(self, prompt="TIMER"): | ||
| with Live(auto_refresh=False) as live: | ||
| while self._countdown: | ||
| console.print(f"{prompt}: {self._countdown}", end="\r") | ||
| self._countdown += timedelta(seconds=-1) | ||
| sleep(1) | ||
| live.refresh() | ||
|
|
||
| def restart(self, start_timer, prompt): | ||
| self._countdown = timedelta(minutes=start_timer) | ||
| self.run(prompt) | ||
|
|
||
|
|
||
| timer_duration = int(input("Duration: ").strip()) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put this into an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, good point. will do that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
| break_duration = int(input("Break Duration: ").strip()) | ||
| console.print("\nCTRL+C to quit") | ||
| while True: | ||
| try: | ||
| timer = PomodoroTimer(start_timer=timer_duration) | ||
| timer.run() | ||
| timer.restart(start_timer=break_duration, prompt="BREAK") | ||
| except KeyboardInterrupt: | ||
| console.print("TIME'S UP") | ||
| break | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rich?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been playing with
richlately and it seems super cool and useful for CLI outputs and layouts.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, need to check that out, maybe we can do an article on the blog ...