做一个好人 发表于 2023-9-13 08:04:11

Python用少量代码即可实现一个二维码识别器源码写法

   有时候来到公司,手上拿了很多东西,一下子就忘记打卡了,所以写了个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()

4414513216511 发表于 2023-9-13 13:05:52

厉害,我挺你,嘻嘻嘻。

216341564213 发表于 2023-9-13 18:07:33

还是看不懂,复杂

1378409920 发表于 2023-9-13 23:09:14

这个好好支持一下

NUNU 发表于 2023-9-14 04:10:55

碉堡了!

企鹅6655 发表于 2023-9-14 09:12:36

感觉不错

哈哈哈哈 发表于 2023-9-14 14:19:57

觅风论坛需要你

jhasgvcah 发表于 2023-9-14 19:27:18

感谢这个i资源

哈哈哈哈 发表于 2023-9-15 00:34:39

谢谢楼主,,,收藏ing

NUNU 发表于 2023-9-15 05:42:00

期待中......
页: [1] 2 3 4 5 6
查看完整版本: Python用少量代码即可实现一个二维码识别器源码写法