用python制作电子时钟包装_Python-使用tkinter canvas绘制的电子时钟

#!/usr/bin/env python

# -*- coding: utf-8 -*-

from tkinter import *

import math

import threading

import time

root = Tk()

cv = Canvas(root, bg='white')

cv.create_oval(10,10,210,210,fill='yellow')

cv.pack()

for num in range(12):

angle=num*30

x1 = abs(round(math.cos(math.pi*angle/180)*95)+110)

y1 = abs(110 - round(math.sin(math.pi*angle/180)*95))

x2 = abs(round(math.cos(math.pi*angle/180)*100)+110)

y2 = abs(110 - round(math.sin(math.pi*angle/180)*100))

if angle not in (0, 90, 180, 270):

cv.create_line(x1, y1, x2, y2)

cv.create_line(110, 10, 110, 20, width=2, fill='red') #

cv.create_text(110, 35, text='')

cv.create_line(110, 200, 110, 210, width=2, fill='red') # 6

cv.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值