moses-palmer / pystray

GNU General Public License v3.0
473 stars 59 forks source link

Notifications do not work on Windows 8 32 bit #50

Open firedm opened 4 years ago

firedm commented 4 years ago

Hello Moses, Thanks for new addition to pystray, I appreciate your work, I already put "pystray" in latest version of my application "PyIDM", everything works great

I downloaded pystray from github and used the example you supplied but couldn't display notification, maybe i am doing something wrong

I am running windows 8-32 bit with python 3.6-32 bit

I am not expert in win32 API, but I think there is something mentioned in plyer balloon tip notification regarding registering a class first

here is plyer balloontip.py link: https://github.com/kivy/plyer/blob/master/plyer/platforms/win/libs/balloontip.py

Also plyer has managed to send notification in linux too, if somehow pystray can do this it will be a great hit

the code i tried:

from pystray import Icon as icon, Menu as menu, MenuItem as item
from PIL import Image
import io, base64

APP_ICON2 = b'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAKfSURB\nVDiNZdNfaNVlHAbwz/n9zu/M6Vz7o41yzplg4BCFolbZWi2FiBIMvQq9qJAuCokugqCWFAgJxSgS\n+kN5Uxb9uVJyVgc0wgg65UpczLl2HHPacM7z23bmOaeLnU6bvlcP7/s8z/d5X94n4Ya1dz3Fp9GF\n1vLmORzDB3T3zWcn/oc9VYy/hd3tssEWAxrErgmNqpHW6he3FnAAL9Cdn2fQU8X4keXiB/f7Vrus\nvFBOSiwSi8wI9Wv0pvuMq/4ej9CdD+cM7n5nmXj7576wsTaW7HpIPEtuqiBXCORErkoJlHT420nN\nq6cl60kfSZTvnPnYN8H9hjR8ckDdzh3Ge08I6m7y444XXTw3VkmSkzItaZ9NBYINIQ+83C7b/pyT\n8ktqBW1trmROyzy7V76YkGxeIZs5WxHHIqGiCYuCC5bMJPHwFgPyQqWWVv2v9ohFZmvrrdy51eFt\nLy0Qz+HF1rvgd02bA7Q0mhKLXDo9VCHd/voembcPuThyuSKeSVXLlc+TirAqQOmaxHUTIi3bugxn\nzspJKdXVe+y9PfZPfqnj+a1zCQVQSmJ4VM26+eJYZOzUgMe/3mes/7zGtSt99cqnzvx23rK1K8Qi\n0VyC4SR6f7B63T2GK+JY5ND217Q8usn4pdip42dM5BOeeONJhw/+pEZev0Y4GtKZHbF090ajQaBU\nMbiSDwz+MWJ48B+ThVAssripwWQ+ITk0qNeaAp4JSY/RefOvbrmrw5BJVTe8x3+4r2/MnctnfTTS\nZEbyXboPln9i57Ep0b0/a75tg1GBksuqF4iXmtFs0ocjTSYs+g67SBfKBukCnZ9NiepPWHXHVVVB\nvWlVCiJFoZK/NDpqTWFusl3XlWlBndsoPoXN5TonMFiu8/t0/zmf/S9tcxBW9J/R4gAAAABJRU5E\nrkJggg==\n'

def create_image():
    buffer = io.BytesIO(base64.b64decode(APP_ICON2))
    img = Image.open(buffer)
    return img

icon('test', create_image(), menu=menu(
    item(
        'With submenu',
        menu(
            item(
                'Show message',
                lambda icon, item: icon.notify('Hello World!')),
            item(
                'Submenu item 2',
                lambda icon, item: icon.remove_notification()))))).run()
moses-palmer commented 4 years ago

I do not have access to the version of Windows that you are running---I have performed my tests on Windows 10.

It is correct that class registration is required before using notifications; that is performed here.

I cannot find any special behaviour introduced after Windows 8 neither for NOTIFYICONDATAW not for Shell_NotifyIconW, and both your sample and the one provided in the pystray documentation work on my system.

Perhaps you have disabled notifications in the Windows settings?

firedm commented 4 years ago

Perhaps you have disabled notifications in the Windows settings?

I believe it’s not disabled because “plyer” notifications work

Really not sure what is the problem Hope someone else could test “pystray notifications” on windows 8 and give us feedback