Don't say anything. First, Python timer for Beginners
Principle: Use Python Turtle Library to make quick drawing, erase screen every second, then get real time of computer, draw again, show dynamic time.
About the number if the picture, can be interpreted as a transistor 8 (7segments), the different numbers are the evolution of it, but to different numbers to achieve the pen, down action, can be different
Import Turtle, Timedef drawgap (): Turtle.penup () turtle.fd (5) def drawLine (draw): Drawgap () Turtle.pendown ()ifDrawElseTurtle.penup () turtle.fd ( +) Drawgap () Turtle.right ( -) def drawdigit (d): DrawLine (True)ifDinch[2,3,4,5,6,8,9]ElsedrawLine (False) #g drawLine (True)ifDinch[0,1,3,4,5,6,7,8,9]ElsedrawLine (False) #c drawLine (True)ifDinch[0,2,3,5,6,8,9]ElsedrawLine (False) #d drawLine (True)ifDinch[0,2,6,8]ElsedrawLine (False) #e Turtle.left ( -) #经历一次右转后, adjust left, direction vertical up DrawLine (True)ifDinch[0,4,5,6,8,9]ElsedrawLine (False) drawLine (True)ifDinch[0,2,3,5,6,7,8,9]ElsedrawLine (False) drawLine (True)ifDinch[0,1,2,3,4,7,8,9]ElsedrawLine (False) turtle.left ( the) Turtle.penup () turtle.fd ( -) def drawdate (date): Turtle.pencolor ('Red') forIinchDate:ifi = ='-': Turtle.write ('when', Font= ('Arial', -,'Normal')) Turtle.pencolor ('Green') TURTLE.FD ( +) Elif I=='=': Turtle.write ('points', Font= ('Arial', -,'Normal')) Turtle.pencolor ('Blue') TURTLE.FD ( +) Elif I=='+': Turtle.write ('seconds', Font= ('Arial', -,'Normal')) Turtle.pencolor ('Yellow') Else: Drawdigit (eval (i)) def init (): Turtle.setup (1920x1080, the,0,0) #设置画布大小 $ $for screen position turtle.speed (Ten) Turtle.penup () turtle.Goto(0,0) TURTLE.FD (- -) Turtle.pensize (5) def main (): whileTrue:turtle.clear () init () time_string= Time.strftime ("%h-%m=%s+", Time.localtime ()) Turtle.getscreen (). Tracer ( -,0) drawdate (time_string) #格式化时间 .- to= Geneva+control input annual Sun and moon Time.sleep (1) Turtle.hideturtle () main ()
Finally, we can use Pyinstaller library to realize the software of Python program EXE.
:\>pip install pyinstaller:\>pyinstaller d:\codes\dpython.py:\>pyinstaller-f dpython.py // You can generate a standalone executable file with the-f parameter for the Python source file
Rottengeek
Original link: http://t.cn/RD2bP69
Python implements a screensaver timer