chore(workflow): update Python version to 3.11 and modify dependencies

Update Python version in GitHub Actions workflow to 3.11 and adjust dependencies, including excluding tkinterdnd2 and adding fallback support.
This commit is contained in:
wood chen 2024-11-16 08:18:44 +08:00
parent b0d557166f
commit 2bfb144320
4 changed files with 37 additions and 18 deletions

View File

@ -43,7 +43,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Download FFmpeg
run: |
@ -86,7 +86,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Download FFmpeg
run: |
@ -107,7 +107,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# 安装基本依赖排除tkinterdnd2
pip install ffmpeg-python Pillow
# 尝试安装tkinterdnd2但允许失败
pip install tkinterdnd2 || echo "tkinterdnd2 installation failed, continuing without it"
pip install pyinstaller
# 创建启动器脚本

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/gui.cpython-311.pyc

32
gui.py
View File

@ -8,7 +8,14 @@ import webbrowser
from threading import Thread
import ffmpeg
import traceback # 用于打印详细错误信息
from tkinterdnd2 import * # 导入拖放支持
try:
from tkinterdnd2 import *
SUPPORT_DND = True
except ImportError:
SUPPORT_DND = False
print("Warning: tkinterdnd2 not available, drag and drop support will be disabled")
class FFmpegInstaller:
@ -263,12 +270,19 @@ class FFmpegInstaller:
class VideoToGifConverter:
def __init__(self):
self.check_ffmpeg_installation()
self.root = TkinterDnD.Tk() # 使用支持拖放的Tk
# 根据是否支持拖放来创建不同的根窗口
if SUPPORT_DND:
self.root = TkinterDnD.Tk()
else:
self.root = tk.Tk()
self.root.title("视频转GIF工具")
# 启用文件拖放
self.root.drop_target_register(DND_FILES)
self.root.dnd_bind("<<Drop>>", self.handle_drop)
# 只在支持拖放时启用相关功能
if SUPPORT_DND:
self.root.drop_target_register(DND_FILES)
self.root.dnd_bind("<<Drop>>", self.handle_drop)
self.setup_ui()
@ -461,6 +475,14 @@ class VideoToGifConverter:
# 状态标签
self.status_label = ttk.Label(self.root, text="就绪")
self.status_label.pack(pady=5)
# 如果不支持拖放,添加提示
if not SUPPORT_DND:
ttk.Label(
self.file_frame,
text="注意:当前版本不支持拖放功能,请使用'选择视频'按钮",
wraplength=300,
foreground="red",
).pack(pady=5)
def browse_output(self):
directory = filedialog.askdirectory()

View File

@ -1,13 +1,6 @@
# 核心依赖
ffmpeg-python>=0.2.0 # FFmpeg Python绑定
Pillow>=9.0.0 # 图像处理库(如果需要预览或其他图像处理功能)
Pillow>=9.0.0 # 图像处理库
# GUI增强可选
ttkthemes>=3.2.0 # 美化GUI主题
ttkwidgets>=0.12.0 # 额外的tkinter部件
# 开发工具(可选)
pytest>=7.0.0 # 测试框架
black>=22.0.0 # 代码格式化
flake8>=4.0.0 # 代码检查
tkinterdnd2>=3.9.0 # 拖放支持
# GUI增强
tkinterdnd2>=0.4.2 # 修改为最新的可用版本