mirror of
https://github.com/RealityNet/kobackupdec.git
synced 2026-06-06 17:58:11 +08:00
build: Add PyInstaller standalone build scripts and app icon
This commit is contained in:
parent
08c3d373e3
commit
564886bf90
6
.gitignore
vendored
6
.gitignore
vendored
@ -28,3 +28,9 @@ desktop.ini
|
|||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
# App Config
|
||||||
|
config.json
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
*.spec
|
||||||
|
|||||||
23
build.py
Normal file
23
build.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import PyInstaller.__main__
|
||||||
|
import tkinterdnd2
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
def build():
|
||||||
|
tkdnd_path = os.path.join(os.path.dirname(tkinterdnd2.__file__), 'tkdnd')
|
||||||
|
|
||||||
|
# Ensure dist and build dirs are clean
|
||||||
|
if os.path.exists('dist'): shutil.rmtree('dist')
|
||||||
|
if os.path.exists('build'): shutil.rmtree('build')
|
||||||
|
|
||||||
|
PyInstaller.__main__.run([
|
||||||
|
'kobackupdec_gui.py',
|
||||||
|
'--name=KoBackupDecryptor',
|
||||||
|
'--onefile',
|
||||||
|
'--windowed',
|
||||||
|
'--icon=app.ico',
|
||||||
|
f'--add-data={tkdnd_path};tkinterdnd2/tkdnd'
|
||||||
|
])
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
build()
|
||||||
19
create_icon.py
Normal file
19
create_icon.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import sys
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
def create_ico(input_path, output_path):
|
||||||
|
img = Image.open(input_path)
|
||||||
|
# Crop to square if necessary
|
||||||
|
width, height = img.size
|
||||||
|
if width != height:
|
||||||
|
min_dim = min(width, height)
|
||||||
|
left = (width - min_dim) / 2
|
||||||
|
top = (height - min_dim) / 2
|
||||||
|
right = (width + min_dim) / 2
|
||||||
|
bottom = (height + min_dim) / 2
|
||||||
|
img = img.crop((left, top, right, bottom))
|
||||||
|
|
||||||
|
img.save(output_path, format="ICO", sizes=[(256, 256), (128, 128), (64, 64), (32, 32), (16, 16)])
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
create_ico(sys.argv[1], sys.argv[2])
|
||||||
Loading…
x
Reference in New Issue
Block a user