该楼层疑似违规已被系统折叠隐藏此楼查看此楼
#coding:utf-8
from Tkinter import *
from math import *
from time import *
def createpoints():
x0=200
y0=200
radius=130
for i in range(1,13):
x=x0+radius*sin(2*pi*i/12)
y=y0-radius*cos(2*pi*i/12)
canvas.create_text(x,y,text=i)
def createline(radius,line_width,rad):
x0=200
y0=200
global List
global i
List=[]
x=x0+radius*sin(rad)
y=y0-radius*cos(rad)
i=canvas.create_line(x0,y0,x,y,width=line_width)
List.append(i)
tk=Tk()
tk.title("时钟")
tk.resizable(0,0)
canvas=Canvas(tk,width=400,height=500,bd=0,highlightthickness=0)
canvas.pack()
tk.update()
canvas.create_oval(50,50,350,350)
createpoints()
while 1:
tm=localtime()
t=asctime(tm)
t_hour=0
if tm.tm_hour<=12:
t_hour=tm_hour
else:
t_hour=tm.tm_hour-12
rad1=2*pi*(t_hour+tm.tm_min/60)/12
rad2=2*pi*(tm.tm_min+tm.tm_sec/60)/60
rad3=2*pi*tm.tm_sec/60
createline(50,6,rad1)
createline(90,3,rad2)
createline(120,1,rad3)
l=canvas.create_text(170,450,text=t)
tk.update()
sleep(1)
for item in List:
canvas.delete(item)
canvas.delete(l)