Skip to content

Commit 0496531

Browse files
author
邹上豪
committed
优化gui
1 parent b88ff77 commit 0496531

3 files changed

Lines changed: 58 additions & 5 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
/build
3+
/dist

Main.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
from tkinter import filedialog, messagebox
44
from pydub import AudioSegment
55

6+
# 无ffmpeg的打包指令:pyinstaller --onefile --windowed Main.py
7+
# 包含ffmpeg打包指令:pyinstaller --onedir --add-binary="C:/Users/Apermesa/Downloads/Compressed/ffmpeg-2024-12-19-git-494c961379-essentials_build/bin/ffmpeg.exe;." --windowed Main.py
8+
# 若要打包无ffmpeg版本,则删除下面这两行
9+
ffmpeg_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "ffmpeg.exe")
10+
AudioSegment.converter = ffmpeg_path
11+
612
def generate_empty_audio(output_file, file_name):
713
"""
814
生成一个无声的短音频文件,包含标准 MP3 元数据
@@ -31,7 +37,8 @@ def embed_file_in_audio(file_path):
3137
if not generate_empty_audio(output_audio_file, file_name_with_extension):
3238
return
3339

34-
output_file = os.path.join(os.path.dirname(file_path), os.path.splitext(file_name_with_extension)[0] + " (embedded).mp3")
40+
output_file = os.path.join(os.path.dirname(file_path),
41+
os.path.splitext(file_name_with_extension)[0] + " (embedded).mp3")
3542
try:
3643
with open(output_audio_file, "rb") as audio, open(file_path, "rb") as file:
3744
with open(output_file, "wb") as output:
@@ -95,16 +102,21 @@ def extract_action():
95102

96103
# 创建主界面
97104
root = tk.Tk()
98-
root.title("文件嵌入与提取工具")
99-
root.geometry("400x200")
105+
root.title("文件伪装音频工具")
106+
root.geometry("300x220")
107+
root.resizable(False, False)
100108

101109
# 嵌入按钮
102-
embed_button = tk.Button(root, text="嵌入文件到音频", command=embed_action, height=2, width=20)
110+
embed_button = tk.Button(root, text="嵌入", command=embed_action, height=2, width=20)
103111
embed_button.pack(pady=20)
104112

105113
# 提取按钮
106-
extract_button = tk.Button(root, text="提取文件从音频", command=extract_action, height=2, width=20)
114+
extract_button = tk.Button(root, text="提取", command=extract_action, height=2, width=20)
107115
extract_button.pack(pady=20)
108116

117+
# 作者标签
118+
author_label = tk.Label(root, text="作者:Apermesa", font=("Arial", 10))
119+
author_label.pack(side="bottom", pady=10)
120+
109121
# 运行主循环
110122
root.mainloop()

Main.spec

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['Main.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[],
9+
hiddenimports=[],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=[],
14+
noarchive=False,
15+
optimize=0,
16+
)
17+
pyz = PYZ(a.pure)
18+
19+
exe = EXE(
20+
pyz,
21+
a.scripts,
22+
a.binaries,
23+
a.datas,
24+
[],
25+
name='Main',
26+
debug=False,
27+
bootloader_ignore_signals=False,
28+
strip=False,
29+
upx=True,
30+
upx_exclude=[],
31+
runtime_tmpdir=None,
32+
console=False,
33+
disable_windowed_traceback=False,
34+
argv_emulation=False,
35+
target_arch=None,
36+
codesign_identity=None,
37+
entitlements_file=None,
38+
)

0 commit comments

Comments
 (0)