moses-palmer / pystray

GNU General Public License v3.0
463 stars 57 forks source link

Regression in win32 since 0.19.0 #115

Closed adamlwgriffiths closed 2 years ago

adamlwgriffiths commented 2 years ago

I'm seeing a few regressions since 0.19.0 when running Windows 10 (both python 3.8 and 3.10).

Using the following code (as the example given on the documentation is not self contained, please update that)

import pystray
from PIL import Image, ImageDraw
import time

def callback(icon):
    image = Image.new('RGBA', (128,128), (255,255,255,255)) # create new image
    percent = 100
    while True:
        img = image.copy()
        d = ImageDraw.Draw(img)
        d.rectangle([0, 128, 128, 128-(percent * 128) / 100], fill='blue')
        icon.icon = img
        time.sleep(1)
        percent -= 5
        if percent < 0:
            percent = 100

image = Image.open("image.jpg") #Battery Status Full
icon = pystray.Icon("Test Icon 1", image)

icon.visible = True
icon.run(setup=callback)

Behaviours:

moses-palmer commented 2 years ago

Thank you for your report.

I have tested your example on the master branch, and the error from 0.19.2 has been fixed. The icon does not, however, show unless I set icon.visible in setup. I will have to look further into this.

moses-palmer commented 2 years ago

After having consulted the documentation, it appears that the icon not appearing when a setup callback is provided is the expected behaviour.

I will now close this issue.