- This is a small software based on pyQT5:
-We have used the well-known Python language
-I am currently developing desktop pet SVIP version 1.1 and using Python as my editor.
Now let me explain in detail its functions:
-First,Animation drag and GIF animation playback
-Second,custom right-click menus can be modified by modifying the menu in config, and scripts can also be customized to simplify computer usage
-Third, customize the bug catching style by simply changing the pet folder and the GIF icon below to achieve the replacement of the bug catching style
-----Follow me for Chinese version(关注我,查看中文版)
--------------------------------------------------------------------------------------
About Right Click Menu Settings:
-The context menu can be customized by editing the menu_config.json file under the config folder to dynamically modify the content of the context menu.
-After this change, only the content is changed, to realize the corresponding function you need to create the corresponding script in the bat folder.
{
"主菜单": [
{
"name": "GPT-academic",
"type": "subprocess.Popen",# 可选type类型:subprocess.run、subprocess.Popen、webbrowser(打开浏览器)
"params": [
"powershell",
"-ExecutionPolicy",
"Bypass",
"-File",
".\\bat\\academic.ps1"
]
},
......
],
"子菜单的名称": [
{
"name": "子菜单的名称",
"type": "使用何种方式打开",
"params": "参数"
},
{#示例 在浏览器中打开网站http://localhost:5244/
"name": "我要看Alist",
"type": "webbrowser",
"params": "http://localhost:5244/"
}
]
......
}
-This is an example of a bat script, usually subprocess.run.
@echo off
start "" "D:\Qingfeng\HeyboxAccelerator\heyboxacc.exe"
start "" "D:\Program Files (x86)\Tencent\TIM\Bin\QQScLauncher.exe"
start "" "D:\Program Files\Steam++\Steam++.exe"
- This is a sample powershell script that generally uses subprocess.Popen
Start-Process "D:\sunshine\Sunshine\SunShine.exe" -WorkingDirectory "D:\sunshine\Sunshine"
Start-Process "C:\Program Files\Oray\SunLogin\SunloginClient\SunloginClient.exe"
Start-Process "C:\Program Files\Tailscale\tailscale-ipn.exe"
-You don't need to configure the script file to open the web page, just modify it directly in the configuration file above
--------------------------------------------------------------------------------------
Custom Styles
-This is the format of the desktop pet styles folder.
-The init file under the pet file holds the desk pet initialization gif file, the file names in this must conform to the following rules
-move.gif is the styleof the table favor when it is dragged.
-start.gif is the style when the favorite is just started.
-stay.gif is the style after the pet has been dragged.
-Then the other gif files below the pet folder are the table favor random play files, which don't need to change their names.
-Just follow the rules above when replacing them.
--------------------------------------------------------------------------------------
Features planned to be added.
-Adding Mobile Functionality
-Access to large language modeling conversations
-Voice dialog, voice wakeup
-Access to agent framework for autonomous dialog and mobility?
-Interact with mouse?
--------------------------------------------------------------------------------------
Not much bullshit! Put on the program:
class DemoWin(QMainWindow):
def __init__(self):
super(DemoWin, self).__init__()
# 初始化宠物
self.select_pet = 'pet'
self.select_music=''
self.pet = []
for i in os.listdir(os.path.abspath(self.select_pet)):
self.pet.append(os.path.join(os.path.abspath(self.select_pet), i))
self.pet.remove(os.path.join(os.path.abspath(self.select_pet), 'init'))
# 初始化窗口
self.initUI()
# 初始化,不规则窗口
# 将窗口设置为无边框、总在最前,并且作为子窗口使用
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.SubWindow)
# 禁用了窗口的自动背景填充
self.setAutoFillBackground(False)
# 将窗口背景设置为透明
self.setAttribute(Qt.WA_TranslucentBackground, True)
# 重新绘制窗口,以便上述设置立即生效
self.repaint()
# 是否跟随鼠标
self.is_follow_mouse = False
# 桌面宠物的坐标
self.w = 1550
self.h = 949
# 设置桌面宠物的初始位置
self.move(self.w, self.h)
# 宠物是否飞行
self.is_flying = None
# 设置托盘选项
iconpath = "./mypetico.ico"
# 右键菜单
quit_action = QAction(u'退出', self, triggered=self.quit)
quit_action.setIcon(QIcon(iconpath))
self.tray_icon_menu = QMenu(self)
self.tray_icon_menu.addAction(quit_action)
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setIcon(QIcon(iconpath))
self.tray_icon.setContextMenu(self.tray_icon_menu)
self.tray_icon.show()
# 窗口透明程度
self.setWindowOpacity(1)
# 改变宠物样式
self.change_pet = ''
self.change_music = ''
# 每隔一段时间做个动作
self.timer = QTimer()
self.timer.timeout.connect(self.randomAct)
self.timer.start(1000)
self.condition = 0
self.talk_condition = 0
# 默认动作为随机1, 飞翔动作为2 左右运动3
self.action = 1
'''随即桌宠皮肤'''
def sent_pet(self, pet):
self.pet = []
for i in os.listdir(os.path.abspath(self.change_pet)):
self.pet.append(os.path.join(os.path.abspath(self.change_pet), i))
self.pet.remove(os.path.join(os.path.abspath(self.change_pet), 'init'))
pass
def music(self,music):
print('music_do')
QSound.play('music/轻音乐/'+music)
#老师就是这个上面这个music函数调用它的时候它不播放音乐。
def initUI(self):
# 将窗口设置为动图大小
self.resize(400, 400)
self.label1 = QLabel("", self)
self.label1.setStyleSheet("font:15pt '楷体';border-width: 1px;color:blue;") # 设置边框
# 使用label来显示动画
self.label = QLabel("", self)
# label大小设置为动画大小
self.label.setFixedSize(200, 200)
self.Action(os.path.join(os.path.abspath(self.select_pet), "init/start.gif"))
self.setWindowTitle("myPet")
def playSound(self):
QSound.play("chicken.wav")
print('playsound_play')
'''鼠标左键按下时, 宠物将和鼠标位置绑定'''
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.is_follow_mouse = True
self.mouse_drag_pos = event.globalPos() - self.pos()
event.accept()
self.setCursor(QCursor(Qt.ClosedHandCursor))
self.Action(os.path.join(os.path.abspath(self.select_pet), "init/move.gif"))
'''鼠标移动, 则宠物也移动'''
def mouseMoveEvent(self, event):
if Qt.LeftButton and self.is_follow_mouse:
self.move(event.globalPos() - self.mouse_drag_pos)
event.accept()
xy = self.pos()
self.w, self.h = xy.x(), xy.y()
pass
'''鼠标释放时, 取消绑定'''
def mouseReleaseEvent(self, event):
if event.button() == Qt.RightButton:
return
self.Action(os.path.join(os.path.abspath(self.select_pet), "init/touch.gif"))
self.is_follow_mouse = False
self.setCursor(Qt.OpenHandCursor)
self.playSound()
'''接触宠物的时候调用'''
def enterEvent(self, event): # 鼠标移进时调用
# print('鼠标移入')
self.Action(os.path.join(os.path.abspath(self.select_pet), "init/touch.gif"))
self.setCursor(Qt.OpenHandCursor)
def mouseDoubleClickEvent(self, event):
print("鸡叫")
self.playSound()
def execute_action(self, action_config):
#print(action_config)
if action_config['type'] == 'subprocess.run':
subprocess.run(action_config['params'], shell=True)
elif action_config['type'] == 'webbrowser':
webbrowser.open(action_config['params'])
elif action_config['type'] == 'subprocess.Popen':
subprocess.Popen(action_config['params'], creationflags=subprocess.CREATE_NEW_CONSOLE)
elif action_config['type'] == 'pet':
self.change_pet = action_config['params'][0]
self.sent_pet(self.change_pet)
self.select_pet = self.change_pet
elif action_config['type'] == 'music':
print('music_down')
self.change_music = action_config['params'][0]
print(self.change_music)
self.music(self.change_music)
#self.playSound()
def contextMenuEvent(self, event):
menus = []
actions = []
action_configs = []
# 读取配置文件
try:
with open("./config/menu_config.json", "r", encoding="utf-8") as config:
menu_config = json.load(config)
except Exception as e:
print(e)
return
# 获取子菜单项
for menu in menu_config:
# print(menu)
menus.append(QMenu(str(menu), self))
# 获取action
for action_config in menu_config[menu]:
# print(action_config)
action_configs.append(action_config)
actions.append(menus[-1].addAction(action_config["name"]))
for i, menu in enumerate(menus):
if i == 0:
continue
menus[0].addMenu(menu)
quitAction = menus[0].addAction("退出")
action = menus[0].exec_(self.mapToGlobal(event.pos()))
if action in actions:
self.execute_action(action_configs[actions.index(action)])
if action == quitAction:
qApp.quit()
'''退出程序'''
def quit(self):
self.close()
sys.exit()
def Action(self, action):
# 设置动画路径
self.movie = QMovie(action)
# 宠物大小
self.movie.setScaledSize(QSize(200, 200))
# 将动画添加到label中
self.label.setMovie(self.movie)
# 开始播放动画
self.movie.start()
'''随机做一个动作'''
def randomAct(self):
# 检测是否飞行
if self.h != 949:
self.playSound()
self.is_flying = True
self.action = 2
else:
self.is_flying = False
self.action = 1
if self.action == 1:
if not self.condition:
print("状态变更")
a = random.choice(self.pet)
print(a)
self.Action(a)
self.condition = 1
else:
print("状态还原")
self.Action(os.path.join(os.path.abspath(self.select_pet), "init/stay.gif"))
self.condition = 0
self.timer.start(random.randint(10, 30) * 100)
elif self.action == 2:
# 实现行进效果
if True:
# 飞行效果
if self.is_flying:
if self.h > 950:
self.h = 0
elif self.h > 940:
self.h += 1
else:
self.h += 10
self.move(self.w, self.h)
self.timer.start(random.randint(10, 30) * 100)
elif self.action == 3:
# self.w
self.move(self.w, self.h)
self.timer.start(random.randint(10, 30) * 10)
This is all the program!!!
--------------------------------------------------------------------------------------
If you want the full program.
-Please add my QQ or WeChat:
My QQ is '2693803445'
My WeChat is 'creategreater'