Skip to content

Commit

Permalink
fix: update executable icon path
Browse files Browse the repository at this point in the history
  • Loading branch information
iholston committed Nov 16, 2023
1 parent cf8c9cb commit 57f7779
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea
__pycache__/
__pycache__/
build
dist
main.spec
10 changes: 9 additions & 1 deletion tray.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pystray
import os
import sys
from PIL import Image


Expand All @@ -7,14 +9,20 @@ class TrayIcon:
def __init__(self, acceptor):
self.name = "Heimerdinger"
self.display_name = "Heimerdinger"
self.image = Image.open("icon.png")
self.icon = "icon.png"
self.image = Image.open(self.resource_path())
self.start_pause = "Pause"
self.acceptor = acceptor
self.start_pause_item = pystray.MenuItem(lambda text: self.start_pause, self.pause)
self.exit_item = pystray.MenuItem("Exit", self.exit)
self.menu = pystray.Menu(self.start_pause_item, self.exit_item)
self.icon = pystray.Icon(self.name, self.image, self.display_name, self.menu)

def resource_path(self):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, self.icon)
return os.path.join(os.path.abspath("."), self.icon)

def run(self):
self.acceptor.run()
self.icon.run()
Expand Down

0 comments on commit 57f7779

Please sign in to comment.