Skip to content

Commit

Permalink
Fix more pyinstalelr bugs aa
Browse files Browse the repository at this point in the history
  • Loading branch information
huantianad committed Jun 30, 2021
1 parent b1b887a commit 46b87a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions LevelSync.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ block_cipher = None
a = Analysis(['run.py'],
pathex=['./'],
binaries=[],
datas=[('res/icon.ico', 'res/icon.ico')],
hiddenimports=[],
datas=[('res/icon.ico', 'res')],
hiddenimports=['pystray._win32'],
hookspath=[],
runtime_hooks=[],
excludes=[],
Expand Down
7 changes: 6 additions & 1 deletion src/initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
def resource_path(relative_path):
"""Get absolute path to resource, relative to .exe, works for dev and for PyInstaller"""

return os.path.join(sys.path[0], relative_path)
if getattr(sys, 'frozen', False):
base_path = os.path.split(sys.executable)[0]
else:
base_path = sys.path[0]

return os.path.join(base_path, relative_path)


def bundled_path(relative_path):
Expand Down
4 changes: 2 additions & 2 deletions src/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def error(message: str) -> None:
notification = Notify()
notification.title = "LevelSync Error!!!!"
notification.message = message
notification.icon = initial.bundled_path('res/icon.ico')
notification.icon = initial.bundled_path(os.path.join('res', 'icon.ico'))
notification.send(block=True)


Expand All @@ -147,7 +147,7 @@ def notification(message: str) -> None:
notification = Notify()
notification.title = "LevelSync"
notification.message = message
notification.icon = initial.bundled_path('res/icon.ico')
notification.icon = initial.bundled_path(os.path.join('res', 'icon.ico'))
notification.send(block=True)


Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def main() -> None:
pystray.MenuItem('Quit', exit)
)

with Image.open(bundled_path('res/icon.ico')) as im:
with Image.open(bundled_path(os.path.join('res', 'icon.ico'))) as im:
im.load()
icon.icon = im

Expand Down

0 comments on commit 46b87a5

Please sign in to comment.