Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import Tk, Canvas
- import datetime, time
- root = Tk()
- canvas = Canvas(width = 400, height = 400, bg = 'deepskyblue')
- canvas.pack()
- today = datetime.datetime.now()
- h = today.hour
- m = today.minute
- s = today.second
- text = canvas.create_text(200,50,anchor = 'n',fill = 'orange', font = 'Verdana 20', text = 'Текущее время')
- text_time = canvas.create_text(200,100,anchor = 'n',fill = 'green', font = 'Verdana 18', text = str(h)+' часов ' + str(m)+' мин '+str(s)+' сек ')
- while True:
- today = datetime.datetime.now()
- h = today.hour
- m = today.minute
- s = today.second
- canvas.itemconfig(text_time, text = str(h)+' часов ' + str(m)+' мин '+str(s)+' сек ')
- root.update_idletasks() # эта и следующая строка очень важны, без них вы не увидите холст
- root.update()
- time.sleep(0.1)
Add Comment
Please, Sign In to add comment