added menu to the icon system tray

master
kirbylife 2019-12-03 03:24:36 -06:00
parent 8333eb92c7
commit 3c84622d6d
1 changed files with 5 additions and 3 deletions

View File

@ -12,8 +12,9 @@ from shutil import rmtree
from threading import Thread from threading import Thread
from time import sleep from time import sleep
import pystray
from PIL import Image, ImageTk from PIL import Image, ImageTk
from pystray import Icon, Menu
from pystray import MenuItem as Item
from requests import post from requests import post
from websocket import WebSocket from websocket import WebSocket
@ -27,7 +28,7 @@ _offline_icon = Image.open("img/icons/offline.png")
_standby_icon = Image.open("img/icons/offline.png") _standby_icon = Image.open("img/icons/offline.png")
class MunyalClient(pystray.Icon): class MunyalClient(Icon):
def __init__(self): def __init__(self):
super(MunyalClient, self).__init__("Munyal") super(MunyalClient, self).__init__("Munyal")
self.icon = _standby_icon self.icon = _standby_icon
@ -49,8 +50,9 @@ class MunyalClient(pystray.Icon):
name="downloader", name="downloader",
daemon=True) daemon=True)
thread_uploader.start() thread_uploader.start()
# thread_downloader.start() thread_downloader.start()
self.run(self.__run) self.run(self.__run)
self.menu = Menu(Item("Exit", lambda *args: sys.exit(0)))
def __run(self, icon): def __run(self, icon):
icon.visible = True icon.visible = True