Mi informacion de contacto
Correo[email protected]
2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
✨✨ Bienvenido al blog de Srlua (づ ̄3 ̄)づ╭❤~✨✨🌟🌟 欢迎各位亲爱的读者,感谢你们抽出宝贵的时间来阅读我的文章。
我是Srlua小谢,在这里我会分享我的知识和经验。🎥
希望在这里,我们能一起探索IT世界的奥妙,提升我们的技能。🔮
记得先点赞👍后阅读哦~ 👏👏
📘📚 所属专栏:Pitón
欢迎访问我的主页:Srlua小谢 获取更多信息和资源。✨✨🌙🌙
Tabla de contenido
Empaqueta los archivos primero
Se puede arrastrar al escritorio ~
Ingrese en la línea de comando, python clock.py 22-28
Las funciones principales son las siguientes:
1. Utilice bibliotecas de dibujo gráfico como Turtle para dibujar un reloj de tubo digital dinámico, en el que las horas, minutos y segundos se distinguen por diferentes colores.
2. Puede configurar el despertador a través del teclado para realizar recordatorios en ventanas emergentes.
3. PaseInstalador de Py Convierta la biblioteca en un archivo ejecutable.
PyInstaller es una biblioteca para empaquetar aplicaciones Python en ejecutables independientes.
Puede empaquetar scripts de Python y dependencias relacionadas (como bibliotecas, archivos de recursos) en un único archivo ejecutable, de modo que los usuarios puedan ejecutar aplicaciones sin instalar un intérprete de Python o bibliotecas relacionadas. Con PyInstaller puede crear fácilmente archivos ejecutables multiplataforma, compatibles con múltiples plataformas, como Windows, Mac y Linux.
clock.py es el nombre del archivo. Si el nombre del archivo es diferente, modifíquelo de acuerdo con el nombre del archivo real.
Significa un recordatorio a las 22:28.
- from turtle import *
- from datetime import datetime
- import time
- import sys
- from tkinter import messagebox, Tk
-
-
- def drawGap():
- penup()
- fd(5)
-
-
- def drawLine(draw):
- drawGap()
- pendown() if draw else penup()
- fd(40)
- drawGap()
- right(90)
-
-
- def drawDigit(d):
- speed(0)
- 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)
- 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)
- left(180)
- penup()
- fd(20)
-
-
- def drawDate(date):
- pencolor('Red')
- for i in date:
- if i == "-":
- write('时', font=('Arial', 24, 'normal'))
- pencolor('Green')
- fd(40)
- elif i == '=':
- write('分', font=('Arial', 24, 'normal'))
- pencolor('Blue')
- fd(40)
- elif i == '+':
- write('秒', font=('Arial', 24, 'normal'))
- else:
- drawDigit(eval(i))
-
-
- def main(alarm_time=None):
- setup(800, 350, 200, 200)
- hideturtle()
- pensize(8)
- tracer(False) # 设置快速模式
-
- root = Tk()
- root.withdraw() # 隐藏主窗口
-
- while True:
- clear() # 清除之前绘制的内容
- penup()
- goto(-300, 0)
- current_time = datetime.now().strftime('%H-%M=%S+')
- drawDate(current_time)
- update() # 手动刷新屏幕
-
- if alarm_time and current_time.startswith(alarm_time):
- messagebox.showinfo("闹钟提醒", "时间到了!")
- alarm_time = None # 清除闹钟时间,防止重复提示
-
- time.sleep(1)
-
-
- if __name__ == "__main__":
- alarm_time = None
- if len(sys.argv) > 1:
- alarm_time = sys.argv[1] # 获取命令行输入的闹钟时间,格式为 HH-MM
- main(alarm_time)
- done()
¡Espero que te ayude! ¡vamos!
Si encuentra útil el contenido de este artículo, no dude en darle me gusta y suscribirse para seguir recibiendo información valiosa. ¡Sinceramente gracias por su atención y apoyo!