Live2dTK
Live2d performance on tkinter based on live2d_py
使用前需要安装第三方库及其他附加库:
pip install Live2dTK
示例:
from tkinter import Tk, Frame
from Live2dTK import Live2dFrame
demo = Tk()
demo.attributes('-transparent', 'black') # 想要实现背景透明,必须有这一行
frame = Frame(demo)
frame.pack()
Debugging = Live2dFrame(frame, model_path=r"E:\IDE\Plugins\live2d\米塔\3.model3.json",
width=1000, height=1000)
Debugging.pack()
demo.mainloop()
模型位置不强求,但仍然建议构建规范的项目目录:
.scr
+-live2d
+model_name
+py_file
结果:
其中,附加函数:
def on_start_callback(cls, group: str, no: int):"""动作开始触发事件"""
def on_finish_callback(cls):"""动作结束调用函数"""
def end(cls):"""结束之后的资源释放事件"""
def touch(self):"""被点击事件"""
该模块主要集成的live2d功能来自live2d-py 可以根据改项目的其他方法改写以实现更多的可玩性,当前模块后续也会封装更多的api。
另附上一个Demo:demo
效果如下:
加油啊,做黄油的大哥哥!
1.0.1更新内容
添加版本选择,初始化时可以根据模型版本选择2/3版本,默认为3
Live2dFrame(master, model_versions=3, model_path=r"...", width=1000, height=1000)
添加帧数控制,当设置帧数大于等于120帧则忽略
Live2dFrame(master, model_path=r"...", fps=120, width=1000, height=1000)
模型点击触发动作,前提是模型文件存在动作
Debugging = Live2dFrame(master, model_path=r"...",fps=120, width=1000, height=1000)
Debugging.pack()
Debugging.bind("<Button-1>", lambda _: Debugging.model.StartRandomMotion()) # 左键点击时触发动作
修复Resources路径处理: RESOURCES_DIRECTORY
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
live2dtk-1.0.1.tar.gz
(6.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file live2dtk-1.0.1.tar.gz.
File metadata
- Download URL: live2dtk-1.0.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
605ead922309123d93c88eb40e521b408345aa535865ecadf94b37d9e81212b1
|
|
| MD5 |
ca29d27f6dfb061a8c87a5ab84935d5f
|
|
| BLAKE2b-256 |
fd8f5fdc17045e48fad36a6986c4a37c81004cc2f278eb4ea118fec8bbd16b8d
|
File details
Details for the file live2dtk-1.0.1-py3-none-any.whl.
File metadata
- Download URL: live2dtk-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1bf483ab5e015a1dc02c4febbd8108dc9fa6675e612e3f30adbb97cdc4fa25f
|
|
| MD5 |
adbb31b083b353fefe84bc2460e870a1
|
|
| BLAKE2b-256 |
77e1365692eb5fc84e1131a3b96aba8be20034b38f20855be6a9cdc5bbf74e60
|