问题描述
Traceback (most recent call last):
File "c:/Users/rdhin/OneDrive/Desktop/Rissistant/cam3.py",line 155,in <module>
event,values = window.read()
File "C:\python38\lib\site-packages\PySimpleGUI\PySimpleGUI.py",line 7568,in Read
results = self._read(timeout=timeout,timeout_key=timeout_key)
File "C:\python38\lib\site-packages\PySimpleGUI\PySimpleGUI.py",line 7623,in _read
self._Show()
File "C:\python38\lib\site-packages\PySimpleGUI\PySimpleGUI.py",line 7371,in _Show
self.NumCols = max(len(row) for row in self.Rows)
ValueError: max() arg is an empty sequence
我不知道是什么原因引起的,但是这是我编写的代码:
# Start the process
if __name__ == "__main__":
# MARK: Setting up the GUI ~ lines 148-
sg.theme('DarkBlue')
layout = [[sg.Text("Hi,I am C.A.M.")],[sg.Text('Enter something in the text field,type the mic button,or say \'hey Cam!\'')],[sg.InputText(default_text="Enter a command here")],[sg.Button("Mic")],[sg.Button("Process")]]
# Create the window
window = sg.Window('C.A.M.')
while True:
event,values = window.read()
if event in (None,'Cancel','Bye'):
break
print(values[0])
解决方法
在查看文档时,您似乎需要将参数layout
添加到sg.Window('C.A.M.')