python tk fps游戏准星

# -- coding: utf-8 --
# from tkinter import *
from tkinter import Tk, PhotoImage, Canvas, BOTH, Y, Frame

x,y = 0,0
ind=1
def refresh():
    canvas.create_rectangle(0, 0, canvas.winfo_width(),
                            canvas.winfo_height(), fill=TRANSCOLOUR,
                            outline=TRANSCOLOUR)
    canvas.create_polygon((80,150),(370,150),(430,365),(25,365)
                              ,fill = '#FF4081', width = 0,tags=('LabelRect'))
    canvas.create_image(200,100,image=fi,anchor="nw")

    tk.after(100, refresh)
def Cavas_Click(event):
    global x, y
    x = event.x
    y = event.y
    print('开始移动')
def Cavas_Release(event):
    x = None
    y = None
def OnMotion(event) :
    global x, y
    deltax = event.x - x
    deltay = event.y - y
    _x = tk.winfo_x() + deltax
    _y = tk.winfo_y() + deltay
    tk.geometry( "+%s+%s" % (_x, _y))

if __name__ == '__main__':
    fip="xb.png"#你的透明背景图片位置
    TRANSCOLOUR = 'gray'

    tk = Tk()
    screenwidth = tk.winfo_screenwidth()
    screenheight = tk.winfo_screenheight()
    dialog_width = 8
    dialog_height = 8
    # 前两个参数是窗口的大小,后面两个参数是窗口的位置
    tk.geometry("%dx%d+%d+%d" % (
    dialog_width, dialog_height, (screenwidth - (dialog_width/1)) / 2, (screenheight - (dialog_height/1)) / 2))



    fi=PhotoImage(file=fip)
    # tk.geometry('500x400+500+150')
    tk.title('透明窗体')
    tk.overrideredirect( True)
    tk.wm_attributes("-topmost", True)    #窗口置顶
    tk.wm_attributes("-disabled", True)   #窗口禁动
    tk.wm_attributes('-transparentcolor', TRANSCOLOUR)
    tk['bg'] = TRANSCOLOUR

    canvas = Canvas(tk,highlightthickness=0)
    canvas.pack(fill=BOTH, expand=Y)
    L1 = Frame(canvas)
    # B1 = Button(L1,text='点击登录')
    # B1.place(relx=0,rely=0,relwidth=1,relheight=1)
    W1 = canvas.create_window((100,300),window=L1,anchor='w',width=120,height=30)

    # tk.after(0, refresh)    #自动刷新
    #
    # framenum = 8 # gif 的帧数需要确定下来
    # giffile = 'xb.png' #找一张白色背景的gif,设置白色为透明
    # frames = [PhotoImage(file=giffile) for i in range(framenum)]


    tk.mainloop()
搜索