使用python tkinter實(shí)現(xiàn)各種個(gè)樣的撩妹鼠標(biāo)拖尾效果
python-tkinter 實(shí)現(xiàn)各種個(gè)樣的撩妹鼠標(biāo)拖尾,效果圖展示:

系統(tǒng)的拖尾已經(jīng)無法滿足我們了,女朋友叫你把鼠標(biāo)拖尾換成她的照片,讓你時(shí)時(shí)刻刻都可以看見她,這個(gè)要求你答不答應(yīng)。
當(dāng)然,這個(gè)要求還是可以滿足一下的,我們來具體看一看吧。
要制作拖尾,首先,我們需要知道鼠標(biāo)的位置,那有沒有獲取鼠標(biāo)位置的方法呢?答案當(dāng)然是有的。因此,我們引用到pyautogui模塊
pip install pyautogui
一、系統(tǒng)拖尾
第一種是最簡(jiǎn)單的一種,通過設(shè)置就可以輕松設(shè)置鼠標(biāo)拖尾,在這里就不詳解了。

二、文藝型拖尾
這個(gè)拖尾殺傷力不大,侮辱性極強(qiáng),給自己增加工作buff。

代碼如下:
import tkinter,time
from tkinter import *
import pyautogui
tk = tkinter.Tk()
tk.overrideredirect(True)
tk["background"] = "white"
tk.wm_attributes('-transparentcolor', 'white')
w = tk.winfo_screenwidth() # 獲取屏幕寬
h = tk.winfo_screenheight() # 獲取屏幕高
cn = Canvas(tk, height=w, width=h, bg="white")
cn.pack()
def update_test(e):
time.sleep(0.1)
cn.delete(tkinter.ALL)
tk.update()
global a
x,y=pyautogui.position()#獲取鼠標(biāo)位置
tk.geometry("180x35+%s+%s" % (x+10, y+10))
cn.create_text(85, 0, text='我的40米大刀')
tk.bind("<Configure>", update_test)
tk.mainloop()
三、實(shí)用型拖尾
這個(gè)拖尾,可以幫助你找到你容易忘記的東西,比如一些快捷鍵,一些工作的事,讓它隨鼠標(biāo)移動(dòng),隨時(shí)提醒你。

代碼如下:
import tkinter,time
from tkinter import *
import pyautogui
tk = tkinter.Tk()
tk.overrideredirect(True)
tk["background"] = "white"
tk.wm_attributes('-transparentcolor', 'white')
w = tk.winfo_screenwidth() # 獲取屏幕寬
h = tk.winfo_screenheight() # 獲取屏幕高
cn = Canvas(tk, height=w, width=h, bg="white")
cn.pack()
def update_test(e):
time.sleep(0.1)
cn.delete(tkinter.ALL)
tk.update()
global a
x,y=pyautogui.position()
tk.geometry("180x35+%s+%s" % (x+10, y+10))
cn.create_text(85, 0, text='ctrl+c 復(fù)制 \n ctrl+v 粘貼', anchor='n')
tk.bind("<Configure>", update_test)
tk.mainloop()
四、愛心拖尾
這個(gè)拖尾對(duì)于單身人士來說傷害性極大,這滿滿的愛意,想要找一個(gè)人快點(diǎn)脫單。哈哈

import tkinter,time
from tkinter import *
from PIL import ImageTk, Image
import pyautogui
tk = tkinter.Tk()
tk.overrideredirect(True)
tk["background"] = "white"
tk.wm_attributes('-transparentcolor', 'white')
image1 = Image.open("愛心.jpg") # 打開圖片
image = image1.resize((50,60)) # 設(shè)置圖片大小
photo = ImageTk.PhotoImage(image) # 引入圖片
image2 = Image.open("愛心.jpg")
image3 = image2.resize((101, 121)) # 設(shè)置圖片大小
photo1 = ImageTk.PhotoImage(image3) # 引入圖片
w = tk.winfo_screenwidth() # 獲取屏幕寬
h = tk.winfo_screenheight() # 獲取屏幕高
cn = Canvas(tk, height=w, width=h, bg="white")
cn.pack()
a=2
def update_test(e):
time.sleep(0.1)
cn.delete(tkinter.ALL)
tk.update()
global a
x,y=pyautogui.position()
tk.geometry("100x120+%s+%s" % (x+10, y+10))
if a==2:
cn.create_image(50, 50, image=photo1)
cn.pack()
a=1
else:
cn.create_image(50, 50, image=photo)
cn.pack()
a=2
tk.bind("<Configure>", update_test)
tk.mainloop()
五、奔跑的火柴人型拖尾
這個(gè)拖尾,可以將圖片替換為其他的動(dòng)作,甚至你還可以直接來上一部動(dòng)畫片都可以。

代碼如下:
import tkinter,time
from tkinter import *
from PIL import ImageTk, Image
import pyautogui
tk = tkinter.Tk()
tk.overrideredirect(True)
tk.wm_attributes('-transparentcolor', '#E0D9BC')
w = tk.winfo_screenwidth() # 獲取屏幕寬
h = tk.winfo_screenheight() # 獲取屏幕高
cn = Canvas(tk, height=h, width=w, bg="white") # bg="pink"
list,list1,a,b=[],[],1,1
for i in range(1,8):
image1 = Image.open("正向火柴人/123_" + str(i) + ".PNG") # 打開圖片
image = image1.resize((100, 100)) # 設(shè)置圖片大小
photo = ImageTk.PhotoImage(image) # 引入圖片
list.append(photo)
image1 = Image.open("反向火柴人/123_" + str(i) + ".PNG") # 打開圖片
image = image1.resize((100, 100)) # 設(shè)置圖片大小
photo = ImageTk.PhotoImage(image) # 引入圖片
list1.append(photo)
def image(list):
global a
for i in range(1, 8):
if a == 7:
a = 1
cn.create_image(50, 50, image=list[0])
a += 1
else:
cn.create_image(50, 50, image=list[a])
a += 1
break
def update_test(e):
time.sleep(0.1)
tk.update()
x,y=pyautogui.position()
tk.geometry("100x100+%s+%s"%(x+10,y+10))
global b
if x<b:image(list)
elif x==b:pass
else:image(list1)
b=x
cn.pack()
tk.bind("<Configure>", update_test)
tk.mainloop()
六、胡桃搖錢拖尾
這款拖尾與奔跑的火柴人相似,但又不完全相似,主要是針對(duì)單一動(dòng)畫制作??梢宰屇闩笥褳槟銛[一整套動(dòng)作,然后移動(dòng)鼠標(biāo)時(shí),你就可以看見你女朋友調(diào)皮的樣子了。

代碼如下:
import tkinter,time
from tkinter import *
from PIL import ImageTk, Image
import pyautogui
tk = tkinter.Tk()
tk.overrideredirect(True)
tk.wm_attributes('-transparentcolor', '#F7FBFB')
w = tk.winfo_screenwidth() # 獲取屏幕寬
h = tk.winfo_screenheight() # 獲取屏幕高
cn = Canvas(tk, height=h, width=w, bg="#F7FBFB")
cn.pack()
list,a=[],1
for i in range(1,37):
image1 = Image.open("胡桃搖錢/胡桃搖錢_" + str(i) + ".JPG") # 打開圖片
image = image1.resize((100, 100)) # 設(shè)置圖片大小
photo = ImageTk.PhotoImage(image) # 引入圖片
list.append(photo)
def update_test(e):
time.sleep(0.05)
cn.delete(tkinter.ALL)
tk.update()
x,y=pyautogui.position()
tk.geometry("100x100+%s+%s"%(x+10,y+10))
global a
cn.create_image(50, 50, image=list[a])
a=a+1
if a==36:a=1
tk.bind("<Configure>", update_test)
tk.mainloop()
七、女朋友或者老婆拖尾
這個(gè)就更強(qiáng)了,一定要給你老婆看一看,你要告訴她,你的拖尾都是她。直接占據(jù)了整個(gè)屏幕。

代碼如下:
import tkinter,time
from tkinter import *
from PIL import ImageTk, Image
import pyautogui
tk = tkinter.Tk()
tk.overrideredirect(True)
tk.wm_attributes('-transparentcolor', '#F7FBFB')
w = tk.winfo_screenwidth() # 獲取屏幕寬
h = tk.winfo_screenheight() # 獲取屏幕高
cn = Canvas(tk, height=h, width=w, bg="#F7FBFB")
cn.pack()
image1 = Image.open("老婆.png") # 打開圖片
image = image1.resize((200, 300)) # 設(shè)置圖片大小
photo = ImageTk.PhotoImage(image) # 引入圖片
def update_test(e):
time.sleep(0.05)
tk.update()
x,y=pyautogui.position()
tk.geometry("200x300+%s+%s"%(x+10,y+10))
cn.create_image(100, 150, image=photo)
tk.bind("<Configure>", update_test)
tk.mainloop()
如果鼠標(biāo)拖尾有段位,你屬于哪個(gè)段位
到此這篇關(guān)于使用python tkinter實(shí)現(xiàn)各種個(gè)樣的撩妹鼠標(biāo)拖尾效果的文章就介紹到這了,更多相關(guān)python tkinter鼠標(biāo)拖尾內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信