脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - 使用python tkinter实现各种个样的撩妹鼠标拖尾效果

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

2022-01-01 00:20大家一起学编程(python) Python

这篇文章主要介绍了使用python tkinter实现各种个样的撩妹鼠标拖尾效果,本文通过实例代码,给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

python-tkinter 实现各种个样的撩妹鼠标拖尾,效果图展示:

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

系统的拖尾已经无法满足我们了,女朋友叫你把鼠标拖尾换成她的照片,让你时时刻刻都可以看见她,这个要求你答不答应。

当然,这个要求还是可以满足一下的,我们来具体看一看吧。

要制作拖尾,首先,我们需要知道鼠标的位置,那有没有获取鼠标位置的方法呢?答案当然是有的。因此,我们引用到pyautogui模块

pip install pyautogui

 

一、系统拖尾

第一种是最简单的一种,通过设置就可以轻松设置鼠标拖尾,在这里就不详解了。

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

 

二、文艺型拖尾

这个拖尾杀伤力不大,侮辱性极强,给自己增加工作buff。

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

代码如下:

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='我的40米大刀')
tk.bind("<Configure>", update_test)
tk.mainloop()

 

三、实用型拖尾

这个拖尾,可以帮助你找到你容易忘记的东西,比如一些快捷键,一些工作的事,让它随鼠标移动,随时提醒你。

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

代码如下:

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 复制 \n ctrl+v 粘贴', anchor='n')
tk.bind("<Configure>", update_test)
tk.mainloop()

 

四、爱心拖尾

这个拖尾对于单身人士来说伤害性极大,这满满的爱意,想要找一个人快点脱单。哈哈

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

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))  # 设置图片大小
photo = ImageTk.PhotoImage(image)  # 引入图片
​
image2 = Image.open("爱心.jpg")
image3 = image2.resize((101, 121))  # 设置图片大小
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()

 

五、奔跑的火柴人型拖尾

这个拖尾,可以将图片替换为其他的动作,甚至你还可以直接来上一部动画片都可以。

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

代码如下:

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))  # 设置图片大小
  photo = ImageTk.PhotoImage(image)  # 引入图片
  list.append(photo)
  image1 = Image.open("反向火柴人/123_" + str(i) + ".PNG")  # 打开图片
  image = image1.resize((100, 100))  # 设置图片大小
  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()

 

六、胡桃摇钱拖尾

这款拖尾与奔跑的火柴人相似,但又不完全相似,主要是针对单一动画制作。可以让你女朋友为你摆一整套动作,然后移动鼠标时,你就可以看见你女朋友调皮的样子了。

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

代码如下:

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))  # 设置图片大小
  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()

 

七、女朋友或者老婆拖尾

这个就更强了,一定要给你老婆看一看,你要告诉她,你的拖尾都是她。直接占据了整个屏幕。

使用python tkinter实现各种个样的撩妹鼠标拖尾效果

代码如下:

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))  # 设置图片大小
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()

如果鼠标拖尾有段位,你属于哪个段位

到此这篇关于使用python tkinter实现各种个样的撩妹鼠标拖尾效果的文章就介绍到这了,更多相关python tkinter鼠标拖尾内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/qq_39046854/article/details/120118960

延伸 · 阅读

精彩推荐