rdhingra001
rdhingra001

Reputation: 23

Python Error: ValueError: max() arg is an empty sequence in PySimpleGUI

When I run the above code, I get this error in the console:

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

I don't know what's causing this issue, but here's the code that I have written:

# 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])

Upvotes: 2

Views: 1642

Answers (1)

hamim
hamim

Reputation: 11

Looking at the documentation it looks like you need to add the argument layout to sg.Window('C.A.M.')

Upvotes: 1

Related Questions