Python Implementation Screensaver timer

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.