其實自己想的就是到時間以后彈窗提示休息就可以了。后來想想還是自己做一個吧。當然首選Python語言。
首先需要一個定時彈窗具體的代碼如下:
程序使用自帶的 Tkinter 不需要安裝其他的包
程序的主要功能:1、啟動以后自動計時 2、計時完成后彈出窗口進行提示 (默認時間為30分鐘)3、點擊確定后重新進行計時
程序的有一些問題:1、界面簡單不精致(不過個人認為先達到功能 )2、休眠時不能夠自動停止計時
# -*- coding: utf-8 -*- import time, sys # 判斷python的版本然后import對應(yīng)的模塊 if sys.version < '3': from Tkinter import * else: from tkinter import * mydelaymin = 30 #窗口提示的延遲時間,以分鐘計 #------------------def------------------- def showMessage(): #show reminder message window root = Tk() #建立根窗口 #root.minsize(500, 200) #定義窗口的大小 #root.maxsize(1000, 400) #不過定義窗口這個功能我沒有使用 root.withdraw() #hide window #獲取屏幕的寬度和高度,并且在高度上考慮到底部的任務(wù)欄,為了是彈出的窗口在屏幕中間 screenwidth = root.winfo_screenwidth() screenheight = root.winfo_screenheight() - 100 root.resizable(False,False) #添加組件 root.title("Warning!!") frame = Frame(root, relief=RIDGE, borderwidth=3) frame.pack(fill=BOTH, expand=1) #pack() 放置組件若沒有則組件不會顯示 #窗口顯示的文字、并設(shè)置字體、字號 label = Label(frame, text="You have been working 30 minutes! Please have a break!!", font="Monotype Corsiva -20 bold") label.pack(fill=BOTH, expand=1) #按鈕的設(shè)置 button = Button(frame, text="OK", font="Cooper -25 bold", fg="red", command=root.destroy) button.pack(side=BOTTOM) root.update_idletasks() root.deiconify() #now the window size was calculated root.withdraw() #hide the window again 防止窗口出現(xiàn)被拖動的感覺 具體原理未知? root.geometry('%sx%s+%s+%s' % (root.winfo_width() + 10, root.winfo_height() + 10, (screenwidth - root.winfo_width())/2, (screenheight - root.winfo_height())/2)) root.deiconify() root.mainloop() #showMessage() while True: time.sleep(mydelaymin*60) #參數(shù)為秒 showMessage()
如果在win下面,可能需要考慮如何自動運行。
我使用的是批處理文件。具體如下:
文件名為:rest_python.bat
內(nèi)容簡單,就一行(如果有多個python版本注意修改):
Java代碼
python E: est.py
同時需要一個后臺運行這個批處理文件的文件。有點麻煩,如果有更簡便的方法歡迎分享。
文件名字為:silent_bat.vbe
內(nèi)容如下:
Java代碼
set ws=wscript.createobject("wscript.shell") ws.run"E: est_python.bat /start", 0
然后把 silent_bat.vbe 文件拖入啟動文件夾即可。(用快捷方式也可以)
注意的幾點:程序使用python2.7 系統(tǒng) win7。
批處理文件需要根據(jù)你的文件存儲位置進行更改。
記得加入啟動文件夾。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com