我想写一个在后台运行的脚本,只要用户不退出程序,脚本就会最小化到托盘图标。我没有也不需要一个漂亮的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()
任何提示都将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐