from tkinter import* import random import tkinter.messagebox window=Tk() window.title('把你坑到哭') window.geometry('800x400') def btn_oncilck(): tkinter.messagebox.showinfo("厉害","不可能,绝对不可能,竟然让你点到了!") btn_Game=Button(window,text='点我啊SB,嘿嘿',font=('宋体',18),command=btn_oncilck) btn_Game.place(x=20,y=50) def msg(event): print('哦耶,碰到了,可没点到') x=random.randint(0,600) y=random.randint(0,300) btn_Game.place(x=x,y=y) btn_Game.bind('<Enter>',msg) mainloop()