Пока получается только через Кнопку Update.
вот код
#!/usr/bin/env python 3 # -*- encoding: utf-8 -*- from PyQt5 import QtGui, QtWidgets import sys, re import urllib.request from bs4 import BeautifulSoup from easygui import msgbox from gi.repository import GLib import datetime import time old = 0 class SystemTrayIcon(QtWidgets.QSystemTrayIcon): def __init__(self, icon, parent=None): QtWidgets.QSystemTrayIcon.__init__(self, icon, parent) menu = QtWidgets.QMenu(parent) changeicon = menu.addAction("Update") exitAction = menu.addAction("Exit") self.setContextMenu(menu) exitAction.triggered.connect(QtWidgets.qApp.quit) changeicon.triggered.connect(self.updateIcon) def updateIcon(self): global old size = len (See()) if size != old: self.setIcon(QtGui.QIcon("gif.gif")) old= size else: self.setIcon(QtGui.QIcon("icon.gif")) def get_html(url): response = urllib.request.urlopen(url) return response.read() def parse(html): soup = BeautifulSoup(html, 'lxml') telo = soup.find('channel') projects =[] for item in telo.find_all('item'): for wer in item.find_all('wf:expiry'): time_s =item.find('pubdate') time_start = time_s.text[-14:-6] time_e = wer.text[-14:-6] time_start=datetime.datetime.strptime(time_start, "%H:%M:%S") time_e =datetime.datetime.strptime(time_e, "%H:%M:%S") time_end = str(time_e - time_start)[-5:-3] projects.append({ 'Событие' : item.title.text , 'Осталось' : time_end }) return projects def See(): global old explanation = str(parse(get_html('http://swordandshield.esy.es/war.php'))) result = re.sub(u'[^А-Яа-яA-Za-z0-9\s]*', u'', explanation) result = re.sub(r'Событие', '\nСобытие:\n', result) size = len (result) if size != old: old= size msgbox ( result, title ='Сигнал') # ВОТ ТУТ должно назначаться новая иконка return result def main(): GLib.timeout_add_seconds(5, See) app = QtWidgets.QApplication(sys.argv) w = QtWidgets.QWidget() trayIcon = SystemTrayIcon(QtGui.QIcon("sp.gif"), w) trayIcon.show() sys.exit(app.exec_()) if __name__ == '__main__': main()