0

why this code doesn't iterate.if it is not iterate then it will not display different icons as mentioned in the if else statement.give me some solution

import time
import pystray
from PIL import Image



img_1 = Image.open("Green.ico")
img_2 = Image.open("blue.ico")

icon = None


def loop_icon_update():
    global icon
    for x in range(10):
        print(x)
        if x % 2 == 0:
            icon = pystray.Icon("Icon_", img_1)
        else:
            icon = pystray.Icon("Icon_", img_2)
        icon.run()
        time.sleep(1)
        icon.stop()


loop_icon_update()
Samathingamajig
  • 11,839
  • 3
  • 12
  • 34

0 Answers0