番茄工作法,一直耳聞,從未實踐過。
之前預(yù)習(xí)迎考,時有動力不足、精力不集中等狀況發(fā)生,效率低下,一天時間不知不覺就過去。
而且對于實際的復(fù)習(xí)時間沒有把握,不知道時間丟到哪里去了,也不知道自己的效率究竟如何,只有模糊的認(rèn)知——不高。
沒有準(zhǔn)確的認(rèn)知,就沒有良好有效的改進(jìn)。
看來沒有點統(tǒng)計數(shù)據(jù)是不行的。
怎么辦呢,要簡單易行的,試試番茄工作法。
怎么用呢,當(dāng)然是使用工具。所謂君子性非異也,善假于物也。
對于我這種以臺式電腦為生產(chǎn)力工具的人,得有個桌面軟件來幫助我。搜索一番找到兩個工具:番茄盒子,番茄土豆,功能很豐富,不過感覺有點繁瑣,對于我這種初步接觸的人不是很友好。
想了想,實際上我要的就是一個簡單直觀的固定幾十分鐘的倒計時顯示,時間到了就提醒,輕松重復(fù)使用。
需求確定后發(fā)現(xiàn),使用python很容易開發(fā)這個小工具,谷歌+stackoverflow很快實現(xiàn)了我的目標(biāo),使用pyinstaller生成exe執(zhí)行文件為9M大小,可以接受。
窗體效果為一個半透明懸浮小框,置于桌面右下角,始終置頂。使用步驟為:點開應(yīng)用程序就開始第一個番茄鐘的倒計時,一般番茄鐘為25+5即25分鐘的工作+5分鐘的休息,我根據(jù)個人喜好改為40+10,40分鐘到后會響鈴提醒,顯示休息10分鐘的倒計時。休息后,點擊懸浮圖標(biāo)即可重新開始。
是不是很容易上手呢,有興趣的朋友可以嘗試,鏈接:http://pan.baidu.com/s/1i4EwWVb 密碼:ugl5
代碼github
效果圖
這個小工具的效果還不錯,總結(jié)下有4個優(yōu)點:
- 能讓我快速開始,快速進(jìn)入狀態(tài),打開電腦后點開程序就直接開始計時,防止拖延。
- 讓我在一段時間內(nèi)有意識地排除其他干擾集中精力去做一件事。
- 能讓我有清晰的時間概念,比如一件事花了多少個番茄鐘,一天內(nèi)實現(xiàn)了多少個番茄鐘,很容易統(tǒng)計。
- 它能提醒我休息,看電腦很容易麻木,然后就陷于低效率工作無法自拔,適當(dāng)放空反而更好,勞逸結(jié)合。
代碼
- 基于tkinter,python自帶的圖形界面框架
# 生成可執(zhí)行文件
# pyinstaller countdown.py --onefile --noconsole --noupx
import time
import datetime
import winsound
import tkinter as tk
time_end = datetime.datetime.now() + datetime.timedelta(minutes=40)
time_zero = datetime.timedelta(seconds=0)
def beep():
global time_end
for i in range(2):
winsound.Beep(440, 250) # frequency, duration
time.sleep(0.25) # in seconds (0.25 is 250ms)
winsound.Beep(600, 250)
time.sleep(0.25)
winsound.PlaySound("SystemExit", winsound.SND_ALIAS)
clock.config(text=u"開始休息")
time_end = datetime.datetime.now() + datetime.timedelta(minutes=10)
clock.after(1000, tick)
def restart():
global time_end
time_end = datetime.datetime.now() + datetime.timedelta(minutes=40)
clock.config(command=lambda: root.destroy())
tick()
def pause():
time.sleep(2)
clock.config(text=u"再戰(zhàn)一回", bg='#dfd')
flag = 1
def tick():
global time_end, flag
deltatime = time_end - datetime.datetime.now()
if deltatime < time_zero:
if flag == 1:
flag = 0
clock.config(text=u"成功番茄", bg='red')
clock.config(command=restart)
clock.after(500, beep)
else:
flag = 1
clock.config(text=u"休息完畢")
clock.after(500, pause)
else:
deltatime = str(deltatime).split('.')[0]
clock.config(text=deltatime)
# calls itself every 1s
# to update the time display as needed
# after為利用tk自身的事件循環(huán)機(jī)制進(jìn)行延時調(diào)用
clock.after(1000, tick)
root = tk.Tk() # create a Tk root window
# root.overrideredirect(True)
# -----------------隱藏標(biāo)題邊框 始-------------------- #
root.attributes('-alpha', 0.0) #For icon
#root.lower()
root.iconify()
window = tk.Toplevel(root)
# -----------------設(shè)定窗口位置 始-------------------- #
w = 140 # width for the Tk root
h = 50 # height for the Tk root
# get screen width and height
ws = root.winfo_screenwidth() # 屏幕尺寸 寬 x
hs = root.winfo_screenheight() # height of the screen 高 y
# calculate x and y coordinates for the Tk root window
x = ws - w - 100
y = hs - h - 60
# set the dimensions of the screen and where it is placed
# root.geometry('%dx%d+%d+%d' % (w, h, x, y))
window.geometry('%dx%d+%d+%d' % (w, h, x, y))
# -----------------設(shè)定窗口位置 終-------------------- #
window.overrideredirect(1) #Remove border
window.attributes('-topmost', 1)
window.attributes('-alpha', 0.5)
#Whatever buttons, etc
# close = tk.Button(window, text = "Close Window", command = lambda: root.destroy())
# -----------------隱藏標(biāo)題邊框 終-------------------- #
# ----------------- 主要控件設(shè)置與主循環(huán) ------------- #
# root.wm_attributes("-topmost", 1) # 窗口置頂
# clock = tk.Label(window, font=('times', 20, 'bold'), bg='green')
clock = tk.Button(window,
font=('times', 20, 'bold'),
bg='#dfd',
command=lambda: root.destroy(),
# command = lambda: root.destroy()
)
clock.pack(fill='both', expand=True)
tick()
window.mainloop()
# another:
# https://stackoverflow.com/questions/10596988/making-a-countdown-timer-with-python-and-tkinter
# tkinter Window Always on Top :
# https://www.daniweb.com/programming/software-development/threads/42766/keeping-python-window-on-top-of-others
# set window postion
# https://stackoverflow.com/questions/14910858/how-to-specify-where-a-tkinter-window-opens
# remove window title bar, border
# https://stackoverflow.com/questions/31085533/how-to-remove-just-the-window-border
# Play simple beep with python without external library
# https://stackoverflow.com/questions/4467240/play-simple-beep-with-python-without-external-library
其他
- 其他人的electron實現(xiàn),略大,40多M: pomolectron