如何解决Python错误:ValueError:maxarg在PySimpleGUI中为空序列
运行上面的代码时,我在控制台中收到此错误:
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.')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。