帮助玩fps的游戏玩家做的一个准星工具,代码如下:import tkinter as tk
import pyautogui
# 获取屏幕宽度和高度
screen_width,screen_height = pyautogui.size()
# 创建一个透明的顶级窗口
window = tk.Tk()
window.attributes("-transparentcolor", "white")
window.attributes("-fullscreen", True)
window.lift()
window.attributes('-topmost', True)
window.configure(bg='white')
# 创建一个画布来绘图
canvas = tk.Canvas(window, bg='white', highlightthickness=0)
canvas.pack(fill=tk.BOTH, expand=tk.YES)
# 绘制十字准星
canvas.create_line(screen_width / 2, screen_height/2+10, screen_width / 2, screen_height/2-10, width=2, fill='red')
canvas.create_line(screen_width/2+10, screen_height / 2, screen_width/2-10, screen_height / 2, width=2, fill='red')
# 开启循环,保持画面不关闭
window.mainloop()
效果图如下:
|