Я пытаюсь включить эти часы на Python, но что-то идет не так. После активации Python Shell просто ничего не делает в принципе. Вот мой код:
#Time
import time
from tkinter import *
tk = Tk()
canvas = Canvas(tk,width = 500,height = 500)
tk.title('Clock')
tk.resizable = (0,0)
year_text = canvas.create_text(20,15,text = 'Today is the unknown day in unkown',font = ('Comic Sans MS',20),state = 'normal')
month_day_text = canvas.create_text(430,15,text = 'Unknown',font = ('Comic Sans MS',20),state = 'normal')
time_text = canvas.create_text(200,230,text = 'Unknown:Unknown:Unknown',font = ('Comic Sans MS',35),state = 'normal')
apm_text = canvas.create_text(235,300,text = 'Unknown',font = ('Comic Sans MS',25),state = 'normal')
activate = False
months = ['January','February','March','April','May','June','July','August','September','October','November','December']
week_days = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
activate = True
while activate == True:
_timenow = time.localtime()
__year = _timenow[0]
__month = _timenow[1]
__day = _timenow[2]
__week_day = _timenow[6]
__hour = _timenow[3]
__minute = _timenow[4]
__second = _timenow[5]
__year_day = _timenow[6]
_year = __year
_month = months[__month - 1]
_day = __day
lday = str(_day)[-1]
_week_day = week_days[__week_day]
_hour = __hour
_minute = __minute
_second = __second
_year_day = __year_day
yday = str(_year_day)[-1]
if lday == '1':
day = str(_day) + 'st'
elif lday == '2':
day = str(_day) + 'nd'
elif lday == '3':
day = str(_day) + 'rd'
elif lday not in ['1','2','3']:
day = str(_day) + 'th'
if _hour == 0:
hour = '12'
apm = 'A.M.'
elif _hour < 12:
hour = str(_hour)
apm = 'A.M.'
elif _hour == 12:
hour = str(_hour)
apm = 'P.M.'
elif _hour >= 13:
hour = str(_hour - 12)
apm = 'P.M.'
if yday == '1':
year_day = str(_year_day) + 'st'
elif yday == '2':
year_day = str(_year_day) + 'nd'
elif yday == '3':
year_day = str(_year_day) + 'rd'
elif yday not in ['1','2','3']:
year_day = str(_year_day) + 'th'
canvas.itemconfig(year_text,text = f'Today is the {year_day} day in {_year}')
canvas.itemconfig(month_day_text,text = f'{_month} {day}')
canvas.itemconfig(time_text,text = f'{hour}:{_minute}:{_second}')
canvas.itemconfig(apm_text,text = f'{apm}')
Это не дает мне холст tkinter. Я думаю, что это как-то связано с while l oop, потому что когда я закрываюсь, он говорит:
Your program is still running!
Do you want to kill it?
Я не знаю, в чем я ошибся.