Python does a "Pomodoro" a small alarm clock program, to improve learning efficiency ah there? Haha

Pomodoro:

The Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s.[1] The technique uses a timer to break down work into intervals, traditionally 25 minutes in length, separated by short breaks. Each interval is known as a pomodoro...

Translation: Learning 25 minutes, playing five minutes until completion

 

First, alarm clock, how to make python playing music: (python3.6)

import subprocess
music = r"D:\CloudMusic\represent.mp3"
subprocess.Popen(["start",music],shell=True)

Note that the command line to knock start xxx.mp3 need you to specify the default program to open mp3 files, my windows computer I Netease cloud music is used.

Temporal logic design, is simple:

 while (true): Learning: timesleep (learning time) rest timesleep (break) 

It has been circulating. So directly on the code:

import subprocess
import time

def playMusic(case):
    if case == 1:
        music = r"D:\CloudMusic\represent.mp3"
    else:
        music = r"D:\CloudMusic\kongbaige.mp3"
    print("Playing Music")
    subprocess.Popen(["start",music],shell=True)

def study():
    print('''             __                      __            __                     
            /  |                    /  |          /  |                    
  _______  _$$ |_    __    __   ____$$ | __    __ $$/  _______    ______  
 /       |/ $$   |  /  |  /  | /    $$ |/  |  /  |/  |/       \  /      \ 
/$$$$$$$/ $$$$$$/   $$ |  $$ |/$$$$$$$ |$$ |  $$ |$$ |$$$$$$$  |/$$$$$$  |
$$      \   $$ | __ $$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |$$ |  $$ |$$ |  $$ |
 $$$$$$  |  $$ |/  |$$ \__$$ |$$ \__$$ |$$ \__$$ |$$ |$$ |  $$ |$$ \__$$ |
/     $$/   $$  $$/ $$    $$/ $$    $$ |$$    $$ |$$ |$$ |  $$ |$$    $$ |
$$$$$$$/     $$$$/   $$$$$$/   $$$$$$$/  $$$$$$$ |$$/ $$/   $$/  $$$$$$$ |
                                        /  \__$$ |              /  \__$$ |
                                        $$    $$/               $$    $$/ 
                                         $$$$$$/                 $$$$$$/ ''')
def rest():
    print('''                                 __     
                                /  |    
  ______    ______    _______  _$$ |_   
 /      \  /      \  /       |/ $$   |  
/$$$$$$  |/$$$$$$  |/$$$$$$$/ $$$$$$/   
$$ |  $$/ $$    $$ |$$      \   $$ | __ 
$$ |      $$$$$$$$/  $$$$$$  |  $$ |/  |
$$ |      $$       |/     $$/   $$  $$/ 
$$/        $$$$$$$/ $$$$$$$/     $$$$/  ''')

#按分钟计时
def run(studyTime,interval):
    while True:
        try:
            playMusic(1) #这里暂停就只能在网易云音乐里关掉了
            study();
            time.sleep(studyTime*60) #就是睡指定时间
            print("学习暂停,进入5分钟休息时间")
            playMusic(2) 
            rest()
            time.sleep(interval*60)#回到循环开头
        except Exception as e:
            print(e)
            
if __name__ == "__main__":
    studyTime = 25
    interval = 5
    run(studyTime,interval)

Where several fonts that can be downloaded from the Internet   WordArt

Such an interface is not finished it. Music by changing their own path. .

The only interface so ------

So I'm a perfectionist ah, no music player interface, by Netease cloud music playback, pause music I feel a little strange, this piece of music or do own a bar. . And then found python winsound only put wav file, and then tkinter this library is studious studious, but I do not want to learn in depth. .

Well, I'm not a perfectionist. . . .

Above that make do with it, but also play MP3, Netease cloud with the good, then what pyinstaller packaged into exe file is not specified directory, is generated

~ / Dist / xxxx.exe inside ~ refers to your personal user directory, windows usually c: // Users // xxxx / dist

Exe file is generated: directly on the desktop can be run. .

effect:

Well, peace of mind 25 minutes to learn, a good five minutes to rest, this universe invincible simple version of the "Pomodoro" (which I just gave him the name) well, yes! !

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_38190111/article/details/89044299