Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 9 - GUI Programming using Tkinter - Programming Exercises - Page 306: 9.11

Answer

code

Work Step by Step

# 9.11 (Display a clock) Write a program that displays a clock to show the current time, # as shown in Figure 9.27a. To obtain the current time, use the datetime class in # Supplement II.B. from datetime import datetime from tkinter import * now = datetime.now().strftime("%H:%M:%S") window = Tk() c = Canvas(window, width=500, height=500, bg="white") c.pack() c.create_oval(50, 50, 450, 450) c.create_text(250, 50, text="12") c.create_text(50, 250, text="9") c.create_text(450, 250, text="3") c.create_text(250, 450, text="6") c.create_text(250, 470, text=now) c.create_line(250,250,100,160,width=2) c.create_line(250,250,230,360,width="3") c.create_line(250,250,300,300) window.mainloop()
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.