Python으로 앉아서 수분 보충 부족을 없애기
오랫동안 계속 앉아있는 것은 더 나쁜 영향을 줄 것입니다.
현재 웰니스 웰빙 시장이 좋은 느낌인 것 같아서 건강해질 수 있는 Windows 앱을 만들었습니다.
대략 1시간마다 서는 것을 촉구하고, 그 1분 후에 다시 앉을 것을 허가하는 취지의 통지가 옵니다.
또한 마찬가지로 수분 보급을 촉구하는 메시지도 화면 오른쪽 하단에 표시됩니다.
이런 느낌
사용법 및 소스
pip에서 win10toast와 schedule, configparser를 install하십시오.
Reminderchan.pyfrom win10toast import ToastNotifier
import time
import schedule
import random
import configparser
toaster = ToastNotifier()
def remind(msg):
toaster.show_toast(msg)
print("notification sent!")
def main():
config_ini = configparser.ConfigParser()
config_ini.read("config.ini", encoding="utf-8")
wakeup = int(config_ini["DEFAULT"]["wakeup"])
sleep = int(config_ini["DEFAULT"]["sleep"])
lang = config_ini["DEFAULT"]["lang"]
print("Your wakeup time is {} and you are scheduled to sleep at {}. your language is {}".format(wakeup,sleep,lang))
if lang == "jp":
for hour in range(wakeup,sleep):
hour = str(hour).zfill(2)
rdm = random.randint(-20,20)
rdm2 = random.randint(-20,20)
minute = 30-rdm
print("{}:{}にスタンドのお知らせを出します".format(hour,minute))
print("{}:{}に水分補給のお知らせを出します".format(hour,30-rdm2))
schedule.every().day.at("{}:{}".format(hour,minute)).do(remind, "立ちましょう。1分程立ってストレッチしましょう")
schedule.every().day.at("{}:{}".format(hour,minute+1)).do(remind, "もう座っても大丈夫です。")
schedule.every().day.at("{}:{}".format(hour,30-rdm2)).do(remind, "水を80ml程度飲みましょう")
ct = 0
while True:
schedule.run_pending()
if ct%3600 == 0:
print("機能チェック")
ct += 1
time.sleep(1)
elif lang == "en":
for hour in range(wakeup,sleep):
hour = str(hour).zfill(2)
rdm = random.randint(-20,20)
rdm2 = random.randint(-20,20)
minute = 30-rdm
print("I will pop stand up notification at {}:{}".format(hour,minute))
print("I will pop up hydration notification at {}:{}".format(hour,30-rdm2))
schedule.every().day.at("{}:{}".format(hour,minute)).do(remind, "Time to Stand! Let's start stretching for 1 minute")
schedule.every().day.at("{}:{}".format(hour,minute+1)).do(remind, "You may sit now.")
schedule.every().day.at("{}:{}".format(hour,30-rdm2)).do(remind, "Please drink at least 80 ml of water to hydrate yourself!")
ct = 0
while True:
schedule.run_pending()
if ct%3600 == 0:
print("Functionality check")
ct += 1
time.sleep(1)
else:
print("something is wrong with config reading process.")
#1時間に80ml
#スタンド1時間程度に一回 1分程
if __name__ == "__main__":
#test
remind("Remineder starts!")
main()
"""
MIT License
Copyright (c) 2021 Lulu-Gustav der Große
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE."""
24시간 계속 통지가 오는 것 이상으로 일어나고 있는 시간만 통지가 오도록 제한을 겁니다.
config.ini에서 평소 기상 시간과 자는 시간을 설정합니다.
일단 lang=en으로 하면 영어로 메시지가 옵니다.
config.ini[DEFAULT]
wakeup = 9
sleep = 23
lang = jp
신경 쓰면 24시간 앉아 버리므로 개인적으로 편리합니다.
Reference
이 문제에 관하여(Python으로 앉아서 수분 보충 부족을 없애기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Lulu_die_Zweite/items/2ee086dd6d2d7349f2bc
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
from win10toast import ToastNotifier
import time
import schedule
import random
import configparser
toaster = ToastNotifier()
def remind(msg):
toaster.show_toast(msg)
print("notification sent!")
def main():
config_ini = configparser.ConfigParser()
config_ini.read("config.ini", encoding="utf-8")
wakeup = int(config_ini["DEFAULT"]["wakeup"])
sleep = int(config_ini["DEFAULT"]["sleep"])
lang = config_ini["DEFAULT"]["lang"]
print("Your wakeup time is {} and you are scheduled to sleep at {}. your language is {}".format(wakeup,sleep,lang))
if lang == "jp":
for hour in range(wakeup,sleep):
hour = str(hour).zfill(2)
rdm = random.randint(-20,20)
rdm2 = random.randint(-20,20)
minute = 30-rdm
print("{}:{}にスタンドのお知らせを出します".format(hour,minute))
print("{}:{}に水分補給のお知らせを出します".format(hour,30-rdm2))
schedule.every().day.at("{}:{}".format(hour,minute)).do(remind, "立ちましょう。1分程立ってストレッチしましょう")
schedule.every().day.at("{}:{}".format(hour,minute+1)).do(remind, "もう座っても大丈夫です。")
schedule.every().day.at("{}:{}".format(hour,30-rdm2)).do(remind, "水を80ml程度飲みましょう")
ct = 0
while True:
schedule.run_pending()
if ct%3600 == 0:
print("機能チェック")
ct += 1
time.sleep(1)
elif lang == "en":
for hour in range(wakeup,sleep):
hour = str(hour).zfill(2)
rdm = random.randint(-20,20)
rdm2 = random.randint(-20,20)
minute = 30-rdm
print("I will pop stand up notification at {}:{}".format(hour,minute))
print("I will pop up hydration notification at {}:{}".format(hour,30-rdm2))
schedule.every().day.at("{}:{}".format(hour,minute)).do(remind, "Time to Stand! Let's start stretching for 1 minute")
schedule.every().day.at("{}:{}".format(hour,minute+1)).do(remind, "You may sit now.")
schedule.every().day.at("{}:{}".format(hour,30-rdm2)).do(remind, "Please drink at least 80 ml of water to hydrate yourself!")
ct = 0
while True:
schedule.run_pending()
if ct%3600 == 0:
print("Functionality check")
ct += 1
time.sleep(1)
else:
print("something is wrong with config reading process.")
#1時間に80ml
#スタンド1時間程度に一回 1分程
if __name__ == "__main__":
#test
remind("Remineder starts!")
main()
"""
MIT License
Copyright (c) 2021 Lulu-Gustav der Große
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE."""
[DEFAULT]
wakeup = 9
sleep = 23
lang = jp
Reference
이 문제에 관하여(Python으로 앉아서 수분 보충 부족을 없애기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Lulu_die_Zweite/items/2ee086dd6d2d7349f2bc텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)