今天分享的是python
GUI开发方面的,我们先来看看效果:
这次实现的功能有:
- 桌面时钟可以时钟保持在所有窗口的最上边,且窗体的透明度为0.8
- 没有了关闭的功能,关闭需要在时钟上按任意键
- 支持跟随鼠标移动
- 支持二进制文件直接运行
那就直接上代码吧:
# -*- encoding: utf-8 -*-
__date__ = '2023/12/04 13:00:32'
import tkinter as tk
import time
class ClockWindow(tk.Tk):
def __init__(self):
super().__init__()
self.overrideredirect(1) # 去除窗口边框
self.wm_attributes("-alpha", 0.8) # 设置透明度
self.wm_attributes("-topmost", True) # 始终处于顶层
self.title('个性化时钟')
self.geometry('300x100')
self.configure(bg='black')
self.time_label = tk.Lab