https://www.tutorialspoint.com/how-to-make-a-system-tray-application-in-tkinter
How to make a system tray application in Tkinter?
How to make a system tray application in Tkinter? A System Tray application is created for the continuous execution of the program. Whenever an application is closed by the user, it will get its state running on the taskbar. To identify a system tray appli
www.tutorialspoint.com
# Import the required libraries
from tkinter import *
from pystray import MenuItem as item
import pystray
from PIL import Image, ImageTk
# Create an instance of tkinter frame or window
win=Tk()
win.title("System Tray Application")
# Set the size of the window
win.geometry("700x350")
# Define a function for quit the window
def quit_window(icon, item):
icon.stop()
win.destroy()
# Define a function to show the window again
def show_window(icon, item):
icon.stop()
win.after(0,win.deiconify())
# Hide the window and show on the system taskbar
def hide_window():
win.withdraw()
image=Image.open("favicon.ico")
menu=(item('Quit', quit_window), item('Show', show_window))
icon=pystray.Icon("name", image, "My System Tray Icon", menu)
icon.run()
win.protocol('WM_DELETE_WINDOW', hide_window)
win.mainloop()
'시행착오 > [python]' 카테고리의 다른 글
[Python] Python 심볼릭 링크 설정 (0) | 2021.08.31 |
---|---|
[python] dictionary(딕셔너리)의 clear(), {} 차이 (0) | 2021.05.20 |
[python] argument가 없는 lambda 람다식 (0) | 2021.05.17 |
[python] 파이썬 daemon 데몬 만들기 (0) | 2021.05.06 |
[python] 로컬 및 원격 서버내 파일/디렉토리 존재 확인법 (0) | 2021.05.04 |