pythonV1V2/第28讲入会考验/课堂成果/课后作业1-调整作品.py
sairate 7df250638d chore: 添加项目基础结构和示例代码
- 创建 .idea 目录和相关配置文件,设置项目结构
- 添加多个课堂成果示例代码,涵盖不同主题和功能
- 创建和配置 .gitignore 文件,忽略特定文件和目录
2025-07-05 09:36:00 +08:00

39 lines
727 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''【课后作业要求】
挑战一:
运用学到的知识对作品进行如下调整:
1.设置窗口为宽度可调整,高度不可调整
2.设置标签字体为“宋体”
3.设置标签背景色(黑、红、黄任选一)
黑色“black”bg="black"
红色“red”bg="red"
黄色“yellow”bg="yellow"
'''
import tkinter as tk
import time
root = tk.Tk()
root.title('大聪明的时钟')
root.geometry('400x80+400+400')
root.resizable(width=True,height=False)
def update_clock():
now = time.strftime('%H:%M:%S')
label.config(text=now)
root.after(1000,update_clock)
label = tk.Label(text='',font=('宋体',60),fg='blue',bg='yellow')
label.pack()
update_clock()
root.mainloop()