鱼C论坛

 找回密码
 立即注册
查看: 3111|回复: 1

[作品展示] 用python做一个番茄钟2.0

[复制链接]
发表于 2020-8-29 18:30:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
记住提取码:h69c
https://pan.baidu.com/s/1UeILTTKnaKIrVzEM45suyg
以下代码是最新的,和链接里的有差别
  1. #曲速飞跃作

  2. import easygui as g
  3. import random
  4. import time as tim
  5. from tkinter import *
  6. import tkinter.font as tkFont
  7. import tkinter.messagebox as messagebox
  8. import pygame
  9. import sys
  10. from pygame.locals import *
  11. import matplotlib.pyplot as plt

  12. a = open('if.txt')
  13. b = a.read()
  14. c = int(b)
  15. if c == 2:
  16.     with open('if.txt','w') as f:
  17.         f.write('1')
  18.     g.msgbox('欢迎来到TurtlrTomato!请先完成初始设置。')
  19.     name = g.enterbox('请问您的姓名?(必填)')
  20.     cf = g.buttonbox('是否设置查看密码?',choices = ("是","否"))
  21.     if cf == "是":
  22.         mima = g.enterbox('密码?(数字)')
  23.         with open('mimas.txt', 'w') as f:
  24.             f.write(str(mima))
  25.         with open('1.txt', 'w') as f:
  26.             f.write(str(1))
  27.     g.msgbox(name + ',欢迎!')
  28. def check():
  29.     a = open('time.txt')
  30.     b = a.read()
  31.     time = len(b)
  32.     msg = "您一共专注了" + str(time) + "次!"
  33.     title = '统计'
  34.     cho = ['饼图',"历史"]
  35.     c7 = g.buttonbox(msg, title, cho)
  36.     if c7 == '饼图':
  37.         a = open('ti.txt')
  38.         b = a.read()
  39.         c = len(b)
  40.         s = b[:c - 1]

  41.         sizes = [int(i) for i in s.split(',')]
  42.         plt.pie(sizes, autopct='%1.1f%%',
  43.                 shadow=True, startangle=90)
  44.         plt.axis('equal')
  45.         plt.show()
  46.     else:
  47.         a = open("history.txt")
  48.         b = a.read()
  49.         g.msgbox(b)

  50. def stop():
  51.     pygame.mixer.music.stop()

  52. def go():
  53.     pygame.mixer.music.play(-1,0)
  54. def ti():
  55.     messagebox.showwarning('警告','您正在专注啊!')
  56.     why = g.enterbox('真可惜。。。\n\n请写下您被迫放弃的原因:')
  57.     import datetime

  58.     nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  59.     with open('history.txt', 'a+') as f:
  60.         f.write(nowTime + '放弃专注' + '\n' + why)
  61.     exit(0)

  62. def big():
  63.     import turtle, time
  64.     def drawGap():
  65.         turtle.penup()
  66.         turtle.fd(5)
  67.     def drawLine(draw):
  68.         drawGap()
  69.         turtle.pendown() if draw else turtle.penup()
  70.         turtle.fd(40)
  71.         drawGap()
  72.         turtle.right(90)
  73.     def drawDigit(d):
  74.         drawLine(True) if d in [2,3,4,5,6,8,9] else drawLine(False)
  75.         drawLine(True) if d in [0,1, 3, 4, 5, 6,7, 8, 9] else drawLine(False)
  76.         drawLine(True) if d in [0, 2, 3, 5, 6, 8, 9] else drawLine(False)
  77.         drawLine(True) if d in [0,2,6,8] else drawLine(False)
  78.         turtle.left(90)
  79.         drawLine(True) if d in [0,4,5,6,8,9] else drawLine(False)
  80.         drawLine(True) if d in [0,2,3,5,6,7,8,9] else drawLine(False)
  81.         drawLine(True) if d in [0,1,2,3,4,7,8,9] else drawLine(False)
  82.         turtle.left(180)
  83.         turtle.penup()
  84.         turtle.fd(20)
  85.     def drawDate(date):
  86.         turtle.pencolor('orange')
  87.         for i in date:
  88.             if i == '-':
  89.                 turtle.write('时',font=('Arial',18,'normal'))
  90.                 turtle.pencolor('orange')
  91.                 turtle.fd(40)
  92.             elif i == '=':
  93.                 turtle.write('分', font=('Arial', 18, 'normal'))
  94.                 turtle.pencolor('orange')
  95.                 turtle.fd(40)
  96.             elif i == '+':
  97.                 turtle.write('秒', font=('Arial', 18, 'normal'))
  98.                 turtle.pencolor('orange')
  99.             else:
  100.                 drawDigit(eval(i))
  101.     def init():
  102.         turtle.setup(1920,1080,0,0)
  103.         turtle.speed(10)
  104.         turtle.penup()
  105.         turtle.goto(0,0)
  106.         turtle.fd(-350)
  107.         turtle.pensize(5)
  108.     def main():
  109.         while True:
  110.             turtle.clear()
  111.             init()
  112.             time_string = time.strftime("%H-%M=%S+", time.localtime())
  113.             turtle.getscreen().tracer(30,0)
  114.             drawDate(time_string)
  115.             time.sleep(1)
  116.             turtle.hideturtle()

  117.     main()


  118. a = open('1.txt')
  119. b = a.read()
  120. e = int(b)
  121. if e == 1:
  122.     d = g.enterbox('查看密码?')
  123.     h = int(d)
  124.     c = open('mimas.txt')
  125.     k = c.read()
  126.     f = int(k)
  127.     if h != f:
  128.         d = g.enterbox('再次输入查看密码?')
  129.         h = int(d)
  130.         c = open('mimas.txt')
  131.         k = c.read()
  132.         f = int(k)
  133.         if h != f:
  134.             exit(0)

  135. while True:
  136.     c = g.buttonbox('TurtleToamto  番茄工作法 2.0\n\n\n点击番茄图标开始专注',title = 'TurtlrTomato',image = 'to.JPG',choices = ('统计','更多','退出'))
  137.     if c == 'to.JPG':
  138.         do = g.enterbox("您要专注于?")
  139.         t = g.enterbox("时长?(一般25分钟)")
  140.         tt = int(t)
  141.         ttt = tt * 60

  142.         pygame.mixer.init()

  143.         pygame.mixer.music.load("chanchanchan.ogg")
  144.         pygame.mixer.music.play(-1, 0)
  145.         finish_sound = pygame.mixer.Sound("finish.ogg")

  146.         root = Tk()

  147.         root.geometry('750x300')
  148.         root.title('番茄ing...')


  149.         canvas = Canvas(root)
  150.         canvas.pack(side=LEFT)
  151.         which = random.randint(1,5)
  152.         
  153.         photo = PhotoImage(file="to.GIF")
  154.         

  155.         imgLabel = Label(root, image=photo)

  156.         imgLabel.pack(side=RIGHT)

  157.         st = Button(root,bg = 'white',text='停止播放',command = stop,anchor='s',relief=GROOVE)
  158.         st.pack(side = 'bottom',fill = 'x')

  159.         go = Button(root,bg = 'white',text='继续播放',command = go,anchor='s',relief=GROOVE)
  160.         go.pack(side = 'bottom',fill = 'x')

  161.         ti = Button(root,bg = 'white',text='放弃',command = ti,anchor='s',relief=GROOVE)
  162.         ti.pack(side = 'bottom',fill = 'x')

  163.         bi = Button(root,bg = 'white',text='全屏时钟',command = big,anchor='s',relief=GROOVE)
  164.         bi.pack(side = 'bottom',fill = 'x')

  165.         ck = Button(root, bg='white', text='统计', command=check, anchor='s', relief=GROOVE)
  166.         ck.pack(side='bottom', fill='x')

  167.         time = ttt
  168.         a = open('whi.txt')
  169.         b = a.read()
  170.         c = int(b)
  171.         ft = tkFont.Font(family='Fixdsys', size=c, weight=tkFont.BOLD)


  172.         def tick():
  173.             canvas.delete(ALL)
  174.             global time
  175.             time -= 1
  176.             canvas.create_text(150, 100, text=str(time), font=ft)
  177.             if time == 0:
  178.                 pygame.mixer.music.stop()
  179.                 finish_sound.play()
  180.                 msg = "恭喜你完成专注(" + str(tt) + "分钟)!"
  181.                 title = "TurtlrTomato"
  182.                 choice = ["完成且退出", "写下专注感悟后退出", "休息一下"]
  183.                 c4 = g.buttonbox(msg, title, choice)
  184.                 if c4 == "完成且退出":
  185.                     import datetime

  186.                     nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  187.                     with open('history.txt', 'a+') as f:
  188.                         f.write(str(nowTime) + str(do) + str(tt) + "分钟")
  189.                         f.write('\r\n')
  190.                     with open('time.txt', 'a+') as f:
  191.                         f.write("1")
  192.                     with open('ti.txt', 'a+') as f:
  193.                         f.write(str(tt) + ',')
  194.                     exit(0)

  195.                 elif c4 == "写下专注感悟后退出":
  196.                     zhuan = g.enterbox("您有什么收获......")
  197.                     import datetime

  198.                     nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  199.                     with open('history.txt', 'a+') as f:
  200.                         f.write(str(nowTime) + str(do) + str(tt) + "分钟" + '\n' + zhuan)
  201.                         f.write('\r\n')
  202.                     with open('time.txt', 'a+') as f:
  203.                         f.write("1")
  204.                     with open('ti.txt', 'a+') as f:
  205.                         f.write(str(tt) + ',')
  206.                     exit(0)

  207.                 elif c4 == "休息一下":
  208.                     tim.sleep(300)
  209.                     zhuan = g.enterbox('休息完成!\n写下您的专注感悟:')
  210.                     import datetime

  211.                     nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  212.                     with open('history.txt', 'a+') as f:
  213.                         f.write(str(nowTime) + str(do) + str(tt) + "分钟" + '\n' + zhuan)
  214.                         f.write('\r\n')
  215.                     with open('time.txt', 'a+') as f:
  216.                         f.write("1")
  217.                     with open('ti.txt', 'a+') as f:
  218.                         f.write(str(tt) + ',')
  219.                     exit(0)

  220.             else:
  221.                 canvas.after(1000, tick)


  222.         canvas.after(1, tick)

  223.         big()

  224.         root.mainloop()

  225.     elif c == "统计":
  226.         check()
  227.     elif c == "更多":
  228.         msg = "更多"
  229.         title = "TurtleTomato"
  230.         choice5 = ["设置开始密码", "清空历史记录",  "自定义计时器大小", "切换白噪音", "关于", "番茄工作法"]
  231.         c5 = g.buttonbox(msg, title, choice5)
  232.         if c5 == "设置开始密码":
  233.             mima = g.enterbox('密码?(数字)')
  234.             with open('mimas.txt', 'w') as f:
  235.                 f.write(str(mima))
  236.             with open('1.txt', 'w') as f:
  237.                 f.write(str(1))

  238.         elif c5 == "关于":
  239.             w = g.buttonbox("2.0.2版本\n\n\n更新了UI界面\n\n\n\n\n简化简化再简化~\n\n\n\n\n作者:曲速飞跃",title = '关于TurtleTomato',choices = ("打开下载界面","打开作者fishc主页","好的ヽ( ̄▽ ̄)و"))
  240.             if w == '打开下载界面':
  241.                 g.msgbox('记住提取码:h69c')
  242.                 import os
  243.                 os.system('"C:/Program Files/Internet Explorer/iexplore.exe" https://pan.baidu.com/s/1UeILTTKnaKIrVzEM45suyg')
  244.             elif w == "打开作者fishc主页":
  245.                 import os
  246.                 os.system('"C:/Program Files/Internet Explorer/iexplore.exe" https://fishc.com.cn/space-uid-948663.html')

  247.         elif c5 == "番茄工作法":
  248.             g.msgbox(
  249.                 "番茄工作法是简单易行的时间管理方法.使用番茄工作法,选择一个待完成的任务,将番茄时间设为25分钟,专注工作,中途不允许做任何与该任务无关的事,直到番茄时钟响起,然后进行短暂休息一下(5分钟就行),然后再开始下一个番茄。每4个番茄时段多休息一会儿。番茄工作法极大地提高了工作的效率,还会有意想不到的成就感。")

  250.         elif c5 == "清空历史记录":
  251.             ww = g.buttonbox("您确定要清空历史记录吗?", title="警告",  choices=("确定", "取消"))
  252.             if ww == "确定":
  253.                 with open('history.txt', 'w') as f:
  254.                     f.write('')
  255.                 with open('ti.txt', 'w') as f:
  256.                     f.write('')
  257.                 with open('time.txt', 'w') as f:
  258.                     f.write('')
  259.                 messagebox.showwarning('警告','已完成!')
  260.         elif c5 == "切换白噪音":
  261.             messagebox.showwarning("本程序不自带可切换的白噪音,请自己下载ogg格式的白噪音,并将它命名为chanchanchan.ogg,把原来的白噪音删除。")
  262.         elif c5 == "自定义计时器大小":
  263.             en = g.enterbox("字号?(标准为80)")
  264.             with open('whi.txt', 'w')  as f:
  265.                 f.write(en)

  266.     elif c == '退出':
  267.         exit(0)
复制代码


恭喜我升级啦!

图片在此

图片在此
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-8-29 18:33:56 | 显示全部楼层
哇!好厉害
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-26 13:37

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表