Added platform-specific icon support for both the running application and compiled executables: New files: - create_icons.py: Script to convert PNG to platform-specific formats - Generates .ico for Windows (16, 32, 48, 256px sizes) - Generates .iconset for macOS (ready for iconutil conversion) - LocalTranscription.png: Source icon image - LocalTranscription.ico: Windows icon file (multi-size) - LocalTranscription.iconset/: macOS icon set (needs iconutil on macOS) GUI changes: - main.py: Set application-wide icon for taskbar/dock - main_window_qt.py: Set window icon for GUI window Build configuration: - local-transcription.spec: Use platform-specific icons in PyInstaller - Windows builds use LocalTranscription.ico - macOS builds use LocalTranscription.icns (when generated) To generate macOS .icns file on macOS: iconutil -c icns LocalTranscription.iconset 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
90 lines
2.7 KiB
Python
90 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Create platform-specific icon files from LocalTranscription.png
|
|
Generates .ico (Windows) and .icns (macOS) from the PNG source.
|
|
"""
|
|
|
|
from PIL import Image
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
def create_ico(png_path, ico_path):
|
|
"""Create Windows ICO file from PNG."""
|
|
img = Image.open(png_path)
|
|
|
|
# ICO files typically contain multiple sizes
|
|
# Windows uses 16, 32, 48, 256 pixel sizes
|
|
sizes = [(16, 16), (32, 32), (48, 48), (256, 256)]
|
|
|
|
# Create list of resized images
|
|
icons = []
|
|
for size in sizes:
|
|
resized = img.resize(size, Image.Resampling.LANCZOS)
|
|
icons.append(resized)
|
|
|
|
# Save as ICO
|
|
img.save(ico_path, format='ICO', sizes=sizes)
|
|
print(f"✓ Created {ico_path}")
|
|
|
|
def create_iconset_for_icns(png_path, iconset_dir):
|
|
"""Create .iconset directory with all required sizes for macOS ICNS."""
|
|
img = Image.open(png_path)
|
|
|
|
# macOS requires these specific sizes and naming
|
|
sizes = {
|
|
'icon_16x16.png': (16, 16),
|
|
'icon_16x16@2x.png': (32, 32),
|
|
'icon_32x32.png': (32, 32),
|
|
'icon_32x32@2x.png': (64, 64),
|
|
'icon_128x128.png': (128, 128),
|
|
'icon_128x128@2x.png': (256, 256),
|
|
'icon_256x256.png': (256, 256),
|
|
'icon_256x256@2x.png': (512, 512),
|
|
'icon_512x512.png': (512, 512),
|
|
'icon_512x512@2x.png': (1024, 1024),
|
|
}
|
|
|
|
iconset_dir.mkdir(exist_ok=True)
|
|
|
|
for filename, size in sizes.items():
|
|
resized = img.resize(size, Image.Resampling.LANCZOS)
|
|
output_path = iconset_dir / filename
|
|
resized.save(output_path, format='PNG')
|
|
|
|
print(f"✓ Created iconset directory: {iconset_dir}")
|
|
print(" To create ICNS on macOS, run:")
|
|
print(f" iconutil -c icns {iconset_dir}")
|
|
|
|
def main():
|
|
"""Main function to create all icon files."""
|
|
script_dir = Path(__file__).parent
|
|
png_path = script_dir / "LocalTranscription.png"
|
|
|
|
if not png_path.exists():
|
|
print(f"✗ Error: {png_path} not found!")
|
|
sys.exit(1)
|
|
|
|
print("Creating platform-specific icons from LocalTranscription.png...")
|
|
print("=" * 60)
|
|
|
|
# Create Windows ICO
|
|
ico_path = script_dir / "LocalTranscription.ico"
|
|
create_ico(png_path, ico_path)
|
|
|
|
# Create macOS iconset (need iconutil on macOS to convert to ICNS)
|
|
iconset_dir = script_dir / "LocalTranscription.iconset"
|
|
create_iconset_for_icns(png_path, iconset_dir)
|
|
|
|
print("=" * 60)
|
|
print("✓ Icon creation complete!")
|
|
print()
|
|
print("Files created:")
|
|
print(f" - {ico_path} (Windows)")
|
|
print(f" - {iconset_dir}/ (macOS - needs iconutil)")
|
|
print()
|
|
print("Note: On macOS, run this to create .icns:")
|
|
print(f" iconutil -c icns {iconset_dir}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|