Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pypiwin32
setuptools
setuptools
Pillow
12 changes: 11 additions & 1 deletion win10toast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# standard library
import logging
import threading
from os import path
from os import path, remove
from time import sleep
from pkg_resources import Requirement
from pkg_resources import resource_filename
Expand Down Expand Up @@ -43,6 +43,7 @@
from win32gui import Shell_NotifyIcon
from win32gui import UpdateWindow
from win32gui import WNDCLASS
from PIL import Image

# ############################################################################
# ########### Classes ##############
Expand Down Expand Up @@ -89,12 +90,21 @@ def _show_toast(self, title, msg,
# icon
if icon_path is not None:
icon_path = path.realpath(icon_path)
if icon_path.split('.')[-1] != '.ico':
img = Image.open(icon_path)
new_name = icon_path.split('.')[:-1] + '.ico'
img.save(new_name)
icon_path = new_name
converted = True
else:
icon_path = resource_filename(Requirement.parse("win10toast"), "win10toast/data/python.ico")
converted = False
icon_flags = LR_LOADFROMFILE | LR_DEFAULTSIZE
try:
hicon = LoadImage(self.hinst, icon_path,
IMAGE_ICON, 0, 0, icon_flags)
if path.exists(new_name and converted):
remove(new_name)
except Exception as e:
logging.error("Some trouble with the icon ({}): {}"
.format(icon_path, e))
Expand Down