Add app icon and update build process
This commit is contained in:
BIN
app_icon.ico
Normal file
BIN
app_icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
BIN
app_icon.png
Normal file
BIN
app_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.0 MiB |
@@ -19,11 +19,16 @@ def build():
|
|||||||
system = platform.system()
|
system = platform.system()
|
||||||
print(f"Detected OS: {system}")
|
print(f"Detected OS: {system}")
|
||||||
|
|
||||||
|
# Determine separator for --add-data
|
||||||
|
sep = ";" if system == "Windows" else ":"
|
||||||
|
|
||||||
|
# Base command
|
||||||
base_cmd = [
|
base_cmd = [
|
||||||
sys.executable, "-m", "PyInstaller",
|
sys.executable, "-m", "PyInstaller",
|
||||||
"--onefile",
|
"--onefile",
|
||||||
"--windowed",
|
"--windowed",
|
||||||
"--paths", "src",
|
"--paths", "src",
|
||||||
|
f"--add-data=app_icon.png{sep}.",
|
||||||
"src/main.py"
|
"src/main.py"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -31,6 +36,8 @@ def build():
|
|||||||
name = "TeletextEditor_Linux"
|
name = "TeletextEditor_Linux"
|
||||||
elif system == "Windows":
|
elif system == "Windows":
|
||||||
name = "TeletextEditor_Windows.exe"
|
name = "TeletextEditor_Windows.exe"
|
||||||
|
# Add icon for Windows executable
|
||||||
|
base_cmd.append("--icon=app_icon.ico")
|
||||||
else:
|
else:
|
||||||
print(f"Unsupported platform: {system}")
|
print(f"Unsupported platform: {system}")
|
||||||
return
|
return
|
||||||
|
|||||||
17
convert_icon.py
Normal file
17
convert_icon.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
from PIL import Image
|
||||||
|
import os
|
||||||
|
|
||||||
|
def convert_to_ico(png_path, ico_path):
|
||||||
|
if not os.path.exists(png_path):
|
||||||
|
print(f"Error: {png_path} not found.")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
img = Image.open(png_path)
|
||||||
|
img.save(ico_path, format='ICO', sizes=[(256, 256), (128, 128), (64, 64), (48, 48), (32, 32), (16, 16)])
|
||||||
|
print(f"Successfully converted {png_path} to {ico_path}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error converting image: {e}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
convert_to_ico("app_icon.png", "app_icon.ico")
|
||||||
18
src/main.py
18
src/main.py
@@ -1,10 +1,28 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
from PyQt6.QtWidgets import QApplication
|
from PyQt6.QtWidgets import QApplication
|
||||||
|
from PyQt6.QtGui import QIcon
|
||||||
from teletext.ui import MainWindow
|
from teletext.ui import MainWindow
|
||||||
|
|
||||||
|
def resource_path(relative_path):
|
||||||
|
""" Get absolute path to resource, works for dev and for PyInstaller """
|
||||||
|
try:
|
||||||
|
# PyInstaller creates a temp folder and stores path in _MEIPASS
|
||||||
|
base_path = sys._MEIPASS
|
||||||
|
except Exception:
|
||||||
|
base_path = os.path.abspath(".")
|
||||||
|
|
||||||
|
return os.path.join(base_path, relative_path)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
|
# Set App Icon
|
||||||
|
icon_path = resource_path("app_icon.png")
|
||||||
|
if os.path.exists(icon_path):
|
||||||
|
app.setWindowIcon(QIcon(icon_path))
|
||||||
|
|
||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
window.show()
|
window.show()
|
||||||
sys.exit(app.exec())
|
sys.exit(app.exec())
|
||||||
|
|||||||
Reference in New Issue
Block a user