#曲速飞跃作
import easygui as g
import random
import time as tim
from tkinter import *
import tkinter.font as tkFont
import tkinter.messagebox as messagebox
import pygame
import sys
from pygame.locals import *
import matplotlib.pyplot as plt
a = open('if.txt')
b = a.read()
c = int(b)
if c == 2:
with open('if.txt','w') as f:
f.write('1')
g.msgbox('欢迎来到TurtlrTomato!请先完成初始设置。')
name = g.enterbox('请问您的姓名?(必填)')
cf = g.buttonbox('是否设置查看密码?',choices = ("是","否"))
if cf == "是":
mima = g.enterbox('密码?(数字)')
with open('mimas.txt', 'w') as f:
f.write(str(mima))
with open('1.txt', 'w') as f:
f.write(str(1))
g.msgbox(name + ',欢迎!')
def check():
a = open('time.txt')
b = a.read()
time = len(b)
msg = "您一共专注了" + str(time) + "次!"
title = '统计'
cho = ['饼图',"历史"]
c7 = g.buttonbox(msg, title, cho)
if c7 == '饼图':
a = open('ti.txt')
b = a.read()
c = len(b)
s = b[:c - 1]
sizes = [int(i) for i in s.split(',')]
plt.pie(sizes, autopct='%1.1f%%',
shadow=True, startangle=90)
plt.axis('equal')
plt.show()
else:
a = open("history.txt")
b = a.read()
g.msgbox(b)
def stop():
pygame.mixer.music.stop()
def go():
pygame.mixer.music.play(-1,0)
def ti():
messagebox.showwarning('警告','您正在专注啊!')
why = g.enterbox('真可惜。。。\n\n请写下您被迫放弃的原因:')
import datetime
nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
with open('history.txt', 'a+') as f:
f.write(nowTime + '放弃专注' + '\n' + why)
exit(0)
def big():
import turtle, time
def drawGap():
turtle.penup()
turtle.fd(5)
def drawLine(draw):
drawGap()
turtle.pendown() if draw else turtle.penup()
turtle.fd(40)
drawGap()
turtle.right(90)
def drawDigit(d):
drawLine(True) if d in [2,3,4,5,6,8,9] else drawLine(False)
drawLine(True) if d in [0,1, 3, 4, 5, 6,7, 8, 9] else drawLine(False)
drawLine(True) if d in [0, 2, 3, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if d in [0,2,6,8] else drawLine(False)
turtle.left(90)
drawLine(True) if d in [0,4,5,6,8,9] else drawLine(False)
drawLine(True) if d in [0,2,3,5,6,7,8,9] else drawLine(False)
drawLine(True) if d in [0,1,2,3,4,7,8,9] else drawLine(False)
turtle.left(180)
turtle.penup()
turtle.fd(20)
def drawDate(date):
turtle.pencolor('orange')
for i in date:
if i == '-':
turtle.write('时',font=('Arial',18,'normal'))
turtle.pencolor('orange')
turtle.fd(40)
elif i == '=':
turtle.write('分', font=('Arial', 18, 'normal'))
turtle.pencolor('orange')
turtle.fd(40)
elif i == '+':
turtle.write('秒', font=('Arial', 18, 'normal'))
turtle.pencolor('orange')
else:
drawDigit(eval(i))
def init():
turtle.setup(1920,1080,0,0)
turtle.speed(10)
turtle.penup()
turtle.goto(0,0)
turtle.fd(-350)
turtle.pensize(5)
def main():
while True:
turtle.clear()
init()
time_string = time.strftime("%H-%M=%S+", time.localtime())
turtle.getscreen().tracer(30,0)
drawDate(time_string)
time.sleep(1)
turtle.hideturtle()
main()
a = open('1.txt')
b = a.read()
e = int(b)
if e == 1:
d = g.enterbox('查看密码?')
h = int(d)
c = open('mimas.txt')
k = c.read()
f = int(k)
if h != f:
d = g.enterbox('再次输入查看密码?')
h = int(d)
c = open('mimas.txt')
k = c.read()
f = int(k)
if h != f:
exit(0)
while True:
c = g.buttonbox('TurtleToamto 番茄工作法 2.0\n\n\n点击番茄图标开始专注',title = 'TurtlrTomato',image = 'to.JPG',choices = ('统计','更多','退出'))
if c == 'to.JPG':
do = g.enterbox("您要专注于?")
t = g.enterbox("时长?(一般25分钟)")
tt = int(t)
ttt = tt * 60
pygame.mixer.init()
pygame.mixer.music.load("chanchanchan.ogg")
pygame.mixer.music.play(-1, 0)
finish_sound = pygame.mixer.Sound("finish.ogg")
root = Tk()
root.geometry('750x300')
root.title('番茄ing...')
canvas = Canvas(root)
canvas.pack(side=LEFT)
which = random.randint(1,5)
photo = PhotoImage(file="to.GIF")
imgLabel = Label(root, image=photo)
imgLabel.pack(side=RIGHT)
st = Button(root,bg = 'white',text='停止播放',command = stop,anchor='s',relief=GROOVE)
st.pack(side = 'bottom',fill = 'x')
go = Button(root,bg = 'white',text='继续播放',command = go,anchor='s',relief=GROOVE)
go.pack(side = 'bottom',fill = 'x')
ti = Button(root,bg = 'white',text='放弃',command = ti,anchor='s',relief=GROOVE)
ti.pack(side = 'bottom',fill = 'x')
bi = Button(root,bg = 'white',text='全屏时钟',command = big,anchor='s',relief=GROOVE)
bi.pack(side = 'bottom',fill = 'x')
ck = Button(root, bg='white', text='统计', command=check, anchor='s', relief=GROOVE)
ck.pack(side='bottom', fill='x')
time = ttt
a = open('whi.txt')
b = a.read()
c = int(b)
ft = tkFont.Font(family='Fixdsys', size=c, weight=tkFont.BOLD)
def tick():
canvas.delete(ALL)
global time
time -= 1
canvas.create_text(150, 100, text=str(time), font=ft)
if time == 0:
pygame.mixer.music.stop()
finish_sound.play()
msg = "恭喜你完成专注(" + str(tt) + "分钟)!"
title = "TurtlrTomato"
choice = ["完成且退出", "写下专注感悟后退出", "休息一下"]
c4 = g.buttonbox(msg, title, choice)
if c4 == "完成且退出":
import datetime
nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
with open('history.txt', 'a+') as f:
f.write(str(nowTime) + str(do) + str(tt) + "分钟")
f.write('\r\n')
with open('time.txt', 'a+') as f:
f.write("1")
with open('ti.txt', 'a+') as f:
f.write(str(tt) + ',')
exit(0)
elif c4 == "写下专注感悟后退出":
zhuan = g.enterbox("您有什么收获......")
import datetime
nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
with open('history.txt', 'a+') as f:
f.write(str(nowTime) + str(do) + str(tt) + "分钟" + '\n' + zhuan)
f.write('\r\n')
with open('time.txt', 'a+') as f:
f.write("1")
with open('ti.txt', 'a+') as f:
f.write(str(tt) + ',')
exit(0)
elif c4 == "休息一下":
tim.sleep(300)
zhuan = g.enterbox('休息完成!\n写下您的专注感悟:')
import datetime
nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
with open('history.txt', 'a+') as f:
f.write(str(nowTime) + str(do) + str(tt) + "分钟" + '\n' + zhuan)
f.write('\r\n')
with open('time.txt', 'a+') as f:
f.write("1")
with open('ti.txt', 'a+') as f:
f.write(str(tt) + ',')
exit(0)
else:
canvas.after(1000, tick)
canvas.after(1, tick)
big()
root.mainloop()
elif c == "统计":
check()
elif c == "更多":
msg = "更多"
title = "TurtleTomato"
choice5 = ["设置开始密码", "清空历史记录", "自定义计时器大小", "切换白噪音", "关于", "番茄工作法"]
c5 = g.buttonbox(msg, title, choice5)
if c5 == "设置开始密码":
mima = g.enterbox('密码?(数字)')
with open('mimas.txt', 'w') as f:
f.write(str(mima))
with open('1.txt', 'w') as f:
f.write(str(1))
elif c5 == "关于":
w = g.buttonbox("2.0.2版本\n\n\n更新了UI界面\n\n\n\n\n简化简化再简化~\n\n\n\n\n作者:曲速飞跃",title = '关于TurtleTomato',choices = ("打开下载界面","打开作者fishc主页","好的ヽ( ̄▽ ̄)و"))
if w == '打开下载界面':
g.msgbox('记住提取码:h69c')
import os
os.system('"C:/Program Files/Internet Explorer/iexplore.exe" https://pan.baidu.com/s/1UeILTTKnaKIrVzEM45suyg')
elif w == "打开作者fishc主页":
import os
os.system('"C:/Program Files/Internet Explorer/iexplore.exe" https://fishc.com.cn/space-uid-948663.html')
elif c5 == "番茄工作法":
g.msgbox(
"番茄工作法是简单易行的时间管理方法.使用番茄工作法,选择一个待完成的任务,将番茄时间设为25分钟,专注工作,中途不允许做任何与该任务无关的事,直到番茄时钟响起,然后进行短暂休息一下(5分钟就行),然后再开始下一个番茄。每4个番茄时段多休息一会儿。番茄工作法极大地提高了工作的效率,还会有意想不到的成就感。")
elif c5 == "清空历史记录":
ww = g.buttonbox("您确定要清空历史记录吗?", title="警告", choices=("确定", "取消"))
if ww == "确定":
with open('history.txt', 'w') as f:
f.write('')
with open('ti.txt', 'w') as f:
f.write('')
with open('time.txt', 'w') as f:
f.write('')
messagebox.showwarning('警告','已完成!')
elif c5 == "切换白噪音":
messagebox.showwarning("本程序不自带可切换的白噪音,请自己下载ogg格式的白噪音,并将它命名为chanchanchan.ogg,把原来的白噪音删除。")
elif c5 == "自定义计时器大小":
en = g.enterbox("字号?(标准为80)")
with open('whi.txt', 'w') as f:
f.write(en)
elif c == '退出':
exit(0)