Partially fix icon in Windows builds

This commit is contained in:
Samuel Sloniker 2024-07-21 14:46:36 -07:00
parent 4bf6d6eb20
commit bb4f87e5ed
4 changed files with 28 additions and 9 deletions

View File

@ -24,11 +24,13 @@ connect to Navpoint Desktop.
## Licensing
Navpoint Desktop is released under the [GNU General Public License
v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), except the file
`navpoint/get_ip.py`, which is released under [Creative Commons
Attribution-ShareAlike 4.0
v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), except the files
`navpoint/get_ip.py` and `navpoint.fix_path`, which are released under
[Creative Commons Attribution-ShareAlike 4.0
International](https://creativecommons.org/licenses/by-sa/4.0/) due to use of
[code published on Stack Overflow](https://stackoverflow.com/a/28950776).
code published on Stack Overflow
([`get_ip.py`](https://stackoverflow.com/a/28950776) and
[`fix_path.py`](https://stackoverflow.com/a/53605128)).
Navpoint Mobile is released under the [GNU General Public License
v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html).

View File

@ -1,3 +1,3 @@
pyinstaller -w -F --hidden-import tornado.web main.py
move dist/main.exe dist/navpoint-windows-%PROCESSOR_ARCHITECTURE%.exe
REM rd /q /s dist
REM md dist
pyinstaller --windowed --onefile --hidden-import tornado.web -i=icon.ico --add-data icon.ico:files --name=navpoint-windows-%PROCESSOR_ARCHITECTURE%.exe main.py

16
navpoint/fix_path.py Normal file
View File

@ -0,0 +1,16 @@
# Copyright 2018 Stack Overflow user "Kamal"
# Copyright 2024 Samuel Sloniker
#
# https://stackoverflow.com/a/53605128
#
# Used, modified, and released under CC BY-SA 4.0:
# https://creativecommons.org/licenses/by-sa/4.0/
import sys
import os.path
def fix_path(path):
if getattr(sys, 'frozen', False):
return os.path.join(sys._MEIPASS, "files", path)
else:
return path

View File

@ -1,5 +1,6 @@
import tkinter as tk
import pyqrcode
import navpoint.fix_path
def run(link):
@ -19,8 +20,8 @@ def run(link):
label.config(image=image)
try:
window.iconbitmap("icon.ico")
except tk.TclError:
window.iconbitmap(navpoint.fix_path.fix_path("icon.ico"))
except ImportError:#tk.TclError:
pass