Fix window icon bundling with executable

This commit is contained in:
DevilXD committed 2021-12-29 14:14:32 +01:00
1 parent c8d3b992d7
commit 931992cb0c
2 files changed
+10 -2

No files matched your search

+9 -1
View File
@@ -1,5 +1,7 @@
from __future__ import annotations
import os
import sys
import asyncio
import logging
import tkinter as tk
@@ -22,6 +24,12 @@ digits = ceil(log10(WS_TOPICS_LIMIT))
WS_FONT = ("Courier New", 10)
def resource_path(relative_path):
"""Get absolute path to resource, works for dev and for PyInstaller"""
base_path = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
class TKOutputHandler(logging.Handler):
def __init__(self, output: GUIManager):
super().__init__()
@@ -656,7 +664,7 @@ class GUIManager:
self._closed = asyncio.Event()
self._root = root = Tk()
root.resizable(False, True)
root.iconbitmap("pickaxe.ico") # window icon
root.iconbitmap(resource_path("pickaxe.ico")) # window icon
root.title(f"Twitch Drops Miner v{__version__} (by DevilXD)") # window title
root.protocol("WM_DELETE_WINDOW", self._on_close)
root.bind_all("<KeyPress-Escape>", self.unfocus)