Ai
4 Star 4 Fork 0

Gitee 极速下载/pysimplegui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/PySimpleGUI/PySimpleGUI
克隆/下载
Demo_System_Tray_Icon.py 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
timkay@not.com 提交于 2024-02-12 23:14 +08:00 . First release of PySimpleGUI 5!
import PySimpleGUI as sg
# import PySimpleGUIWx as sg
# import PySimpleGUIQt as sg
"""
System Tray Icon
Your very own peronsal status monitor in your system tray
Super easy to use.
1. Find an icon file or use this default
2. Create your menu defintion
3. Add if statements to take action based on your input
Note from the imports that this code works on all PySimpleGUI ports (except Web).
For the tkinter port, however, the icon isn't located in the system tray. Instead it's located just above
the system tray in the form of what looks like an "icon" on your desktop. It's actually a very small window.
In June 2021 a new package was added to the PySimpleGUI family - psgtray
With this package, you can get a real system tray icon while using tkinter rather than a desktop-icon that this
demo is demonstrating. The Demo Program - Demo_psgtray_Tray_Icon_Tkinter - shows how to integrate it with PySimpleGUI
Copyright 2022-2023 PySimpleSoft, Inc. and/or its licensors. All rights reserved.
Redistribution, modification, or any other use of PySimpleGUI or any portion thereof is subject to the terms of the PySimpleGUI License Agreement available at https://eula.pysimplegui.com.
You may not redistribute, modify or otherwise use PySimpleGUI or its contents except pursuant to the PySimpleGUI License Agreement.
"""
menu_def = ['UNUSED', ['My', '&Simple::my key', 'Has Sub', ['1','2'], '---', 'Menu', 'E&xit']]
tray = sg.SystemTray(menu=menu_def, data_base64=sg.DEFAULT_BASE64_ICON)
while True:
event = tray.read()
print(event)
if event == 'Exit':
break
elif event == 'Menu':
tray.show_message('Title', 'Hey, you clicked Menu!')
tray.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/pysimplegui.git
git@gitee.com:mirrors/pysimplegui.git
mirrors
pysimplegui
pysimplegui
master

搜索帮助