стрелочные часы python, не отображается окно

Почему не выводится окно с часами? писала в Thonny - не выводится, в Jupyter online notebook out:<main.ClockSimpleGui at 0x7f4d184c9710>

from tkinter import *
import math
from datetime import datetime

class ClockSimpleGui:
    def _init_(self):
        window = Tk()
        window.title("Curent Time") 
        WIDTH = 200
        HEIGHT = 200
        radius = WIDTH / 2.4
        secondHandLength = radius * 0.8
        minuteHandLength = radius * 0.65
        hourHandLength = radius * 0.5
        
        canvas = Canvas(window, bg="white", width=WIDTH, height=HEIGHT)
        canvas.pack()
        canvas.create_oval(WIDTH/2-radius, HEIGHT/2-radius, \
                          WIDTH/2+radius, HEIGHT/2+radius)
        
        canvas.create_text(WIDTH/2-radius+5, HEIGHT/2, text="9")
        canvas.create_text(WIDTH/2+radius-5, HEIGHT/2, text="3")
        canvas.create_text(WIDTH/2, HEIGHT/2-radius+5, text="12")
        canvas.create_text(WIDTH/2, HEIGHT/2+radius-5, text="6")
        time_now = datetime.now()
        print(time_now.second)
        
        xCenter = WIDTH / 2
        yCenter = HEIGHT / 2
        second = time_now.second
        x_second = xCenter + secondHandLength * math.sin(second * (2 * math.pi / 60))
        y_second = yCenter - secondHandLength * math.cos(second * (2 * math.pi / 60))
        canvas.create_line(xCenter, yCenter, x_second, y_second, fill="red")
        
        minute = time_now.minute
        print(minute)
        x_minute = xCenter + minuteHandLength * math.sin(minute * (2 * math.pi / 60))
        y_minute = xCenter - minuteHandLength * math.cos(minute * (2 * math.pi / 60))
        canvas.create_line(xCenter, yCenter, x_minute, y_minute, fill="green")
        
        hour = time_now.hour
        hour = hour if hour < 12 else hour - 12 
        print(hour)
        x_hour = xCenter + hourHandLength * math.sin(hour * (2 * math.pi / 12))
        y_hour = yCenter - hourHandLength * math.cos(hour * (2 * math.pi / 12))
        canvas.create_line(xCenter, yCenter, x_hour, y_hour, fill="blue")
        
        timestr = "{}:{}:{}".format(hour if int(hour) < 12 else int(hour-12), minute, second)
        print(timestr)
        
        window.mainloop()
          
ClockSimpleGui()


Ответы (0 шт):