https://evileg.com/ru/post/68/
sys.exit()
"https://stackoverflow.com/questions/758256/pyqt4-minimize-to-tray
# Python 3
import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 6 )
import ctypes
notepad_handle = ctypes.windll.user32.FindWindowW(None, "Untitled - Notepad")
ctypes.windll.user32.ShowWindow(notepad_handle, 6)
notepad_handle = ctypes.windll.user32.FindWindowW(u"Notepad", None)
ctypes.windll.user32.ShowWindow(notepad_handle, 6)
from pystray import MenuItem as item
import pystray
from PIL import Image
import tkinter as tk
window = tk.Tk()
window.title("Title")
def quit_window(icon, item):
icon.stop()
window.destroy()
def show_window(icon, item):
icon.stop()
window.after(0,window.deiconify)
def withdraw_window():
window.withdraw()
image = Image.open("icon.ico")
menu = (item('Quit', quit_window), item('Show', show_window))
icon = pystray.Icon("name", image, "title", menu)
icon.run()
window.protocol('WM_DELETE_WINDOW', withdraw_window)
window.mainloop()