LoginSignup
4
1

More than 5 years have passed since last update.

ターミナルで時間を知らせる

Last updated at Posted at 2018-12-20

時刻を知らせる

初歩的なものですが,投稿の練習も兼ねてやってみたいと思います.
(自分の目も含めて)


#coding:utf-8
# まずは,入力した時間になったらターミナルで知らせてくれるものを作ってみる
from datetime import datetime
from time import sleep
print(datetime.now())
my_time_hour=int(input("時間を入力してください:"))
my_time_minute=int(input())
while True:
    h=int(datetime.now().hour)
    m=int(datetime.now().minute)
    s=int(datetime.now().second)
    if my_time_hour == h and my_time_minute==m:
        print(str(h)+":"+str(m))
        print("おしらせします")
        break
    num=60-s#CPUの消費量を抑えるためにために,残りの時間をsleepにする.
    sleep(num)

結果:
2018-12-21 01:26:14.396535
時間を入力してください:1
27
1:27
おしらせします

これからすること

tkinterを使い,GUIでできるようにしていく.
・入力した時間になると,画面に新たなウインドウを生成し,時刻を知らせてくれる.
・また,時刻だけではなく,アラームなどの機能をつけ,入力した時間経つと同じく知らせてくれるようにする.
・できたら->知らせるときに音も同時に鳴らせるようにする
・音を複数つけ,選択できるようにする

4
1
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1