python中的sys.exit给出了SystemExit错误pystray

问题描述

我正在运行一个PYSTRAY图标,该图标将启动控制台程序。当我尝试使用此代码停止

def stop_rtd():
    print("Stopping RTD")
    sys.exit()
    icon.stop()

系统抛出此错误

An error occurred when calling message handler
Traceback (most recent call last):
  File "C:\Users\ramac\AppData\Local\Programs\Python\python37\lib\site-packages\pystray\_win32.py",line 389,in _dispatcher
    uMsg,lambda w,l: 0)(wParam,lParam) or 0)
  File "C:\Users\ramac\AppData\Local\Programs\Python\python37\lib\site-packages\pystray\_win32.py",line 209,in _on_notify
    descriptors[index - 1](self)
  File "C:\Users\ramac\AppData\Local\Programs\Python\python37\lib\site-packages\pystray\_base.py",line 267,in inner
    callback(self)
  File "C:\Users\ramac\AppData\Local\Programs\Python\python37\lib\site-packages\pystray\_base.py",line 368,in __call__
    return self._action(icon,self)
  File "C:\Users\ramac\AppData\Local\Programs\Python\python37\lib\site-packages\pystray\_base.py",line 463,in wrapper0
    return action()
  File "C:/Tej/GitHub/Python/YahooDLs/try_systray.py",line 16,in stop_rtd
    sys.exit()
SystemExit

RTD是永久的控制台程序。它停止,但图标继续,并且控制台没有关闭关闭控制台后,程序退出,图标关闭

我正在Windows10上运行它

请帮助我解决这个问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)