Skip to content

Commit

Permalink
include icon with pypi and pyinstaller builds
Browse files Browse the repository at this point in the history
  • Loading branch information
j5155 committed May 28, 2024
1 parent 3a85506 commit ad05b92
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion REVHubInterface.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ from PyInstaller.utils.hooks import collect_data_files
from setuptools_scm import get_version, _cli
_cli.main(["--force-write-version-files"])

datas = []
datas = [('./REVHubInterface/org.unofficialrevport.REVHubInterface.png', '.')]
datas += collect_data_files('sv_ttk')
binaries = []
hiddenimports = []
tmp_ret = collect_all('REVHubInterface')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]

print(datas)

block_cipher = None

Expand Down
15 changes: 12 additions & 3 deletions REVHubInterface/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,13 +1133,22 @@ def initwindow():
from REVHubInterface._version import __version__
version = __version__
except ModuleNotFoundError:
version = "DEV BUILD"
version = "dev"


xroot.title(f'REV Hub Interface - Community Edition - v{version}')
try:
from pathlib import Path
icon = PhotoImage(file=Path(__file__).with_name('org.unofficialrevport.REVHubInterface.png'))
xroot.iconphoto(False, icon)
except TclError:
print("Couldn't find bundled icon, falling back to cwd icon")
try:
icon = PhotoImage(file='org.unofficialrevport.REVHubInterface.png')
xroot.iconphoto(False, icon)
except TclError as e:
print(e)

icon = Image("photo", file="org.unofficialrevport.REVHubInterface.png")
xroot.tk.call('wm','iconphoto',xroot._w,icon) # based on https://stackoverflow.com/a/52843705

app = Application(xroot)
xroot.protocol('WM_DELETE_WINDOW', app.joinThreads)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Issues = "https://github.com/unofficial-rev-port/REVHubInterface/issues"
dependencies = { file = ["requirements.txt"] }
[tool.setuptools]
packages = ["REVHubInterface"]
[tool.setuptools.package-data]
REVHubInterface = ["org.unofficialrevport.REVHubInterface.png"]
[project.gui-scripts]
revhubinterface = "REVHubInterface.__main__:initwindow"
[tool.setuptools_scm]
Expand Down

0 comments on commit ad05b92

Please sign in to comment.