马上注册,结交更多易友,享用更多功能,让你轻松玩转觅风论坛。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
有时候来到公司,手上拿了很多东西,一下子就忘记打卡了,所以写了个Python脚本,开启自启弹出提醒。今天我们就用Python用少量代码即可实现一个二维码识别器源码写法
- import tkinter as tk
-
- def close_window():
- root.destroy()
-
- def popup_menu(event):
- menu.post(event.x_root, event.y_root)
-
- def toggle_text_color():
- if text_label.cget("fg") == "#ffffff":
- text_label.config(fg="#000000")
- else:
- text_label.config(fg="#ffffff")
- root.after(500, toggle_text_color) # 500毫秒后再次调用自身
-
- root = tk.Tk()
- root.overrideredirect(True) # 隐藏窗口边框
-
- window_width = 1200
- window_height = 450
-
- screen_width = root.winfo_screenwidth()
- screen_height = root.winfo_screenheight()
-
- x_coordinate = (screen_width - window_width) // 2
- y_coordinate = (screen_height - window_height) // 2
-
- root.geometry(f"{window_width}x{window_height}+{x_coordinate}+{y_coordinate}")
- root.configure(bg="#ff0000")
-
- menu = tk.Menu(root, tearoff=0)
- menu.add_command(label="退出", command=close_window)
-
- root.bind("<Button-3>", popup_menu) # 右键点击触发弹出菜单
-
- # 添加文本标签
- text_label = tk.Label(root, text="上班打卡提醒~", font=("Arial", 70), fg="#ffffff", bg="#ff0000")
- text_label.place(relx=0.5, rely=0.5, anchor="center")
-
- # 开始文字颜色闪烁
- toggle_text_color()
-
- root.mainloop()
复制代码
|
|