当前位置: 首页 > wzjs >正文

wordpress 首页重定向优化软件seo排名

wordpress 首页重定向,优化软件seo排名,百度推广做网站,广州网络推广seo下面是一个使用Python创建的简单桌面小宠物应用。这个小宠物会在桌面上游荡,可以响应鼠标点击,并且有简单的动画效果。 import tkinter as tk import random import time from PIL import Image, ImageTk import os import sysclass DesktopPet:def __i…

下面是一个使用Python创建的简单桌面小宠物应用。这个小宠物会在桌面上游荡,可以响应鼠标点击,并且有简单的动画效果。

import tkinter as tk
import random
import time
from PIL import Image, ImageTk
import os
import sysclass DesktopPet:def __init__(self, root):self.root = rootself.root.overrideredirect(True)  # 移除窗口边框self.root.wm_attributes("-topmost", True)  # 窗口置顶self.root.wm_attributes("-transparentcolor", "white")  # 设置白色为透明色# 设置窗口大小和初始位置self.width = 100self.height = 100screen_width = self.root.winfo_screenwidth()screen_height = self.root.winfo_screenheight()self.x = random.randint(0, screen_width - self.width)self.y = random.randint(0, screen_height - self.height)# 设置窗口位置self.root.geometry(f"{self.width}x{self.height}+{self.x}+{self.y}")# 创建画布self.canvas = tk.Canvas(self.root, width=self.width, height=self.height, highlightthickness=0, bg='white')self.canvas.pack()# 加载宠物图像self.load_images()self.current_image_index = 0self.pet_image = self.canvas.create_image(50, 50, image=self.images[0])# 初始化变量self.direction_x = random.choice([-3, -2, -1, 1, 2, 3])self.direction_y = random.choice([-3, -2, -1, 1, 2, 3])self.last_move_time = time.time()self.move_delay = 0.05  # 移动延迟(秒)self.last_animation_time = time.time()self.animation_delay = 0.2  # 动画延迟(秒)self.is_sleeping = False# 绑定事件self.root.bind("<Button-1>", self.on_click)  # 鼠标左键点击self.root.bind("<Button-3>", self.on_right_click)  # 鼠标右键点击self.root.bind("<B1-Motion>", self.on_drag)  # 拖动宠物# 开始移动self.move()def load_images(self):# 创建宠物图像self.images = []# 正常状态图像for i in range(4):img = Image.new('RGBA', (100, 100), (255, 255, 255, 0))self.create_pet_image(img, i)self.images.append(ImageTk.PhotoImage(img))# 睡觉状态图像img_sleep = Image.new('RGBA', (100, 100), (255, 255, 255, 0))self.create_sleeping_pet(img_sleep)self.sleep_image = ImageTk.PhotoImage(img_sleep)def create_pet_image(self, img, frame):# 绘制宠物身体from PIL import ImageDrawdraw = ImageDraw.Draw(img)# 身体(圆形)body_color = (255, 200, 200)  # 浅粉色draw.ellipse([20, 20, 80, 80], fill=body_color)# 耳朵draw.ellipse([15, 15, 35, 35], fill=body_color)draw.ellipse([65, 15, 85, 35], fill=body_color)# 眼睛(根据帧数变化位置,产生眨眼效果)eye_color = (0, 0, 0)if frame == 3:  # 眨眼帧draw.ellipse([35, 45, 45, 50], fill=eye_color)draw.ellipse([55, 45, 65, 50], fill=eye_color)else:draw.ellipse([35, 40, 45, 50], fill=eye_color)draw.ellipse([55, 40, 65, 50], fill=eye_color)# 嘴巴(微笑)draw.arc([35, 50, 65, 70], start=0, end=180, fill=eye_color, width=2)# 腮红blush_color = (255, 150, 150)draw.ellipse([25, 55, 35, 65], fill=blush_color)draw.ellipse([65, 55, 75, 65], fill=blush_color)def create_sleeping_pet(self, img):# 绘制睡觉状态的宠物from PIL import ImageDrawdraw = ImageDraw.Draw(img)# 身体(圆形)body_color = (255, 200, 200)  # 浅粉色draw.ellipse([20, 20, 80, 80], fill=body_color)# 耳朵draw.ellipse([15, 15, 35, 35], fill=body_color)draw.ellipse([65, 15, 85, 35], fill=body_color)# 闭着的眼睛draw.line([35, 45, 45, 45], fill=(0, 0, 0), width=2)draw.line([55, 45, 65, 45], fill=(0, 0, 0), width=2)# Zzz... 睡眠符号draw.text((70, 30), "Zzz", fill=(100, 100, 255))def move(self):current_time = time.time()# 移动宠物if current_time - self.last_move_time > self.move_delay:screen_width = self.root.winfo_screenwidth()screen_height = self.root.winfo_screenheight()# 更新位置new_x = self.x + self.direction_xnew_y = self.y + self.direction_y# 边界检测if new_x <= 0 or new_x >= screen_width - self.width:self.direction_x *= -1new_x = max(0, min(new_x, screen_width - self.width))if new_y <= 0 or new_y >= screen_height - self.height:self.direction_y *= -1new_y = max(0, min(new_y, screen_height - self.height))self.x = new_xself.y = new_y# 更新窗口位置self.root.geometry(f"+{int(self.x)}+{int(self.y)}")self.last_move_time = current_time# 更新动画if current_time - self.last_animation_time > self.animation_delay:if not self.is_sleeping:self.current_image_index = (self.current_image_index + 1) % 4self.canvas.itemconfig(self.pet_image, image=self.images[self.current_image_index])self.last_animation_time = current_time# 随机改变方向if random.random() < 0.01:  # 1%的几率self.direction_x = random.choice([-3, -2, -1, 1, 2, 3])self.direction_y = random.choice([-3, -2, -1, 1, 2, 3])# 随机进入睡眠状态if not self.is_sleeping and random.random() < 0.002:  # 0.2%的几率self.is_sleeping = Trueself.canvas.itemconfig(self.pet_image, image=self.sleep_image)self.root.after(5000, self.wake_up)  # 5秒后醒来# 继续移动self.root.after(10, self.move)def wake_up(self):self.is_sleeping = Falsedef on_click(self, event):# 当点击宠物时,改变方向self.direction_x = random.choice([-3, -2, -1, 1, 2, 3])self.direction_y = random.choice([-3, -2, -1, 1, 2, 3])# 显示点击效果self.canvas.create_oval(event.x-10, event.y-10, event.x+10, event.y+10, outline="red", width=2, tags="click")self.root.after(200, lambda: self.canvas.delete("click"))def on_right_click(self, event):# 右键点击退出self.root.destroy()def on_drag(self, event):# 拖动宠物self.x = self.root.winfo_x() + event.x - self.width // 2self.y = self.root.winfo_y() + event.y - self.height // 2self.root.geometry(f"+{int(self.x)}+{int(self.y)}")def main():root = tk.Tk()root.config(bg='white')  # 设置背景色为白色(透明色)pet = DesktopPet(root)root.mainloop()if __name__ == "__main__":main()

如何运行这个程序
确保你已安装Python(建议Python 3.6或更高版本)

安装必要的依赖库:

pip install pillow

将上面的代码保存为desktop_pet.py

运行程序:

python desktop_pet.py

这个程序不需要任何外部图像文件,所有图形都是使用Pillow库动态生成的,因此可以直接运行而无需额外的资源文件。

http://www.dtcms.com/wzjs/287716.html

相关文章:

  • 做网站的背景怎么做中国大数据平台官网
  • 大渡口区建委网站google 谷歌
  • 武汉网站建设whjzyh如何做网站网页
  • 医疗网站建设基本流程seo关键词优化排名推广
  • 做镜像网站利润营销技巧在线完整免费观看
  • 链接网站开发需要多少钱网站推广软件下载
  • 自适应的网站百度站长电脑版
  • 工程建设项目哈尔滨优化网站方法
  • 网站服务商查询色盲测试图第五版
  • 网站服务器上的跳转选择怎么做四川疫情最新消息
  • 做网站靠流量挣钱网络营销首先要
  • 厦门网站seo外包网站优化排名易下拉霸屏
  • 商丘企业网站建设推荐百度竞价排名危机事件
  • 团购网站经营模式网站seo推广计划
  • 中国建设银行网站开通短信服务百度收录提交申请
  • abc网站建设怎么样网络推广员具体做什么的
  • 改版一个网站多少钱某企业网站的分析优化与推广
  • 网站管理系统安装搜狐三季度营收多少
  • 惠州住房和城乡建设厅网站seo优化服务是什么
  • 工业园做网站的公司互联网营销方案
  • 贵阳网站建设黔搜网页制作免费模板
  • 网站建设昆明seo建站公司推荐
  • 任县建设局网站网络优化公司有哪些
  • 小辣椒昆明网站开发向日葵seo
  • 南阳做网站公司电话网站搜索引擎优化的基本内容
  • 北京做网站定制价格seo推广关键词公司
  • 手机端网站首页怎么做网络培训
  • 微网站开发平台免费建站哪个网站最好
  • 网站模板生成河北网站seo策划
  • 什么网站可以做卡首屏淘口令权威发布