当我执行下面的代码时,它运行良好,没有任何问题。但是当我尝试通过我的 PyCharm 停止按钮直接关闭 GUI 窗口时,它显示了多行的回溯警报。
import PySimpleGUI as sg
label = sg.Text('this is my first GUI')
add_button = sg.Button('add')
user_input = sg.InputText(tooltip='enter something here')
window = sg.Window('Hello world', layout=[[label, user_input, add_button]])
window.read()
window.close()
我想摆脱这个警告信息
Traceback (most recent call last):
File "C:\Users\HP\PycharmProjects\pythonProject\gui.py", line 9, in <module>
window.read()
File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 10075, in read
results = self._read(timeout=timeout, timeout_key=timeout_key)
File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 10146, in _read
self._Show()
File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 9886, in _Show
StartupTK(self)
File "C:\Users\HP\PycharmProjects\pythonProject\venv\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 16935, in StartupTK
window.TKroot.mainloop()
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1458, in mainloop
self.tk.mainloop(n)
KeyboardInterrupt