[PYTHON] I made a kitchen timer to be displayed on the status bar!

background

I want a kitchen timer. But with apps, I can't always see it by opening the browser. Then I thought that the iPhone would be fine, but I couldn't touch my cellphone! !!

I want a kitchen timer that doesn't take up space where I can always see it! that? The status bar at the top of the Mac is good! Let's make it!

I tried to make it like this.

How to make

I referred to this article. https://qiita.com/hartmann16325/items/8667611fcaf68b9a948b

Since I use python, I checked and found that it is possible to operate in the status bar by using a library called rumps.

I've posted it on GitHub, so if you'd like, please! https://github.com/tokky08/Kitchen_timer

@rumps.clicked(u'Half an hour')
def selectTimer(sender):
    global minute
    minute = 30

    global start
    start = time.time()

Here is the creation of the menu bar.


@rumps.timer(1)
def dispTimer(sender):
    
    timer_minute = str(minute-1)
    timer_second = str(second - int(time.time() - start) % 60)

    remaining_minute = int(time.time() - start) // 60
    timer_minute = str(int(timer_minute) - remaining_minute)

    if int(timer_minute) < 0:
        app.title = "TIME UP"
        if int(timer_minute) == -1 and int(timer_second) == 58:
            rumps.notification(message="Please stop working! !! !!", title="TIME UP!", subtitle="")


    else:
        if int(timer_second) < 10:
            timer_second = "0" + timer_second

        app.title = "remaining time:" + timer_minute + ":" + timer_second

Here this function is executed every second. I think it is divided into minutes and seconds.

For minutes, time.time ()-start is calculated as the number of seconds from the beginning of the countdown minus the time this function was executed. And second is 59 here. second-int (time.time ()-start) indicates that it decreases by 1 second. The reason why it is% 60 is that it does not become negative.

Seconds represent the minutes elapsed in remaining_minute. You can represent the remaining minutes by subtracting it from the selected time.

Summary

I thought about it and researched it, and it took 6 hours to complete. Even if it looks easy, there are some challenges when it comes to making it. Still, the idea can be realized and programming is interesting! I think.

Please point out any mistakes.

Recommended Posts

I made a kitchen timer to be displayed on the status bar!
I made a simple timer that can be started from the terminal
I made a program to look up words on the window (previous development)
I made a command to markdown the table clipboard
I made a function to check the model of DCGAN
I made a VGG16 model using TensorFlow (on the way)
I tried to register a station on the IoT platform "Rimotte"
I made a command to display a colorful calendar in the terminal
I made a script to display emoji
I want to display the progress bar
[Python] A progress bar on the terminal
[Django] I made a field to enter the date with 4 digit numbers
Semi-automatically generate a description of the package to be registered on PyPI
I made a library konoha that switches the tokenizer to a nice feeling
I made a program to check the size of a file in Python
I made a function to see the movement of a two-dimensional array (Python)
I made a POST script to create an issue on Github and register it in the Project
I made a tool to estimate the execution time of cron (+ PyPI debut)
I made an appdo command to execute a command in the context of the app
I made a tool to compile Hy natively
I made a tool to generate Markdown from the exported Scrapbox JSON file
I made a tool to automatically back up the metadata of the Salesforce organization
I made a tool to get new articles
I made a script to record the active window using win32gui of Python
I did a little research on the class
I want to be notified when the command operation is completed on linux!
[Python] I made a system to introduce "recipes I really want" from the recipe site!
It was a life I wanted to OCR on AWS Lambda to locate the characters.
I want to take a screenshot of the site on Docker using any font
I made a small donation to the non-profit organization "Open Source Robot Foundation" OSRF
I made a command to wait for Django to start until the DB is ready
How to test the current time with Go (I made a very thin library)
I made a library to separate Japanese sentences nicely
I made a script to put a snippet in README.md
I made a Python module to translate comment outs
I want to find a popular package on PyPi
I made a code to convert illustration2vec to keras model
I made a Python3 environment on Ubuntu with direnv.
I want a Spotify sleep timer on my PC
I made a python library to do rolling rank
I tried to notify the honeypot report on LINE
〇✕ I made a game
I don't like to be frustrated with the release of Pokemon Go, so I made a script to detect the release and tweet it
I made a tool to get the answer links of OpenAI Gym all at once
I made a class to get the analysis result by MeCab in ndarray with python
I made a program to collect images in tweets that I liked on twitter with Python
[Atcoder] [C ++] I made a test automation tool that can be used during the contest
I made a function to crop the image of python openCV, so please use it.
[Shell startup] I tried to display the shell on the TV with a cheap Linux board G-cluster
I made a tool to automatically generate a simple ER diagram from the CREATE TABLE statement
I scraped the Organization member team and made a ranking
I made a package to filter time series with python
I made a command to generate a table comment in Django
I made a tool to create a word cloud from wikipedia
I made a dot picture of the image of Irasutoya. (part1)
I wrote a script to combine the divided ts files
Listen to a novel that will be on Amazon Polly
I made a rigid Pomodoro timer that works with CUI
I made a dot picture of the image of Irasutoya. (part2)
[Titan Craft] I made a tool to summon a giant to Minecraft
I tried changing the python script from 2.7.11 to 3.6.0 on windows10