我想编写一个在后台运行的脚本,只要用户不退出程序,就会最小化到托盘图标。我没有也不需要花哨的 GUI,所以我只使用infi systray
为了这。
我需要脚本休眠一段时间,但我需要能够通过右键单击托盘图标来关闭它。当脚本运行时,我无法执行此操作,因为While True
陈述。
from infi.systray import SysTrayIcon
from win10toast import ToastNotifier
import time
starttime = time.time()
toaster = ToastNotifier()
def startTimer(systray):
while True:
toaster.show_toast("test1", "test1", duration=5)
toaster.show_toast("test2", "test2", duration=5)
time.sleep(60 - ((time.time() - starttime) % 60.0))
menu_options = (("Start", None, startTimer),)
systray = SysTrayIcon("icon.ico", "test", menu_options)
systray.start()
任何提示将非常感谢。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)