Skip to content

Instantly share code, notes, and snippets.

@benstigsen
Created January 5, 2020 20:10
Show Gist options
  • Select an option

  • Save benstigsen/0c575f79c950a2557a8358ad11f963e0 to your computer and use it in GitHub Desktop.

Select an option

Save benstigsen/0c575f79c950a2557a8358ad11f963e0 to your computer and use it in GitHub Desktop.

Revisions

  1. Benjamin Stigsen revised this gist Jan 5, 2020. No changes.
  2. Benjamin Stigsen created this gist Jan 5, 2020.
    38 changes: 38 additions & 0 deletions PomodoroWin.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    import time, winsound, os

    def clear():
    os.system("cls||clear")

    def playTone(frequency, duration, repeat):
    for _ in range(repeat):
    winsound.Beep(frequency, duration)

    def work(duration = 1200, text = "-"):
    playTone(1300, 100, 2)

    for (i) in range(10):
    clear()
    print(f"Work | {text} | {((duration / 10) * (10 - i)) / 60} minutes\n")
    time.sleep(duration / 10)

    def pause(duration = 300, text = "-"):
    playTone(1000, 150, 3)

    for (i) in range(10):
    clear()
    print(f"Break | ({text}) | {((duration / 10) * (10 - i)) / 60} minutes\n")
    time.sleep(duration / 10)

    def start(rounds, work_duration, break_duration):
    while True:
    for (i) in range(rounds):
    work(duration = work_duration, text = f"{i + 1}/{rounds}")

    if (i == rounds - 1):
    # Long Break (5x short break duration)
    pause(break_duration * 5)
    else:
    # Regular Break
    pause(duration = break_duration, text = f"{i + 1}/{rounds}")

    start(4, 1200, 300)