Error "Your row is not an iterable (e.g. a list)" when creating window layout in PySimpleGUI

Question:

I want to code a tiny Calculator with PySimpleGUI but, when I run the Code it shows an error:

ERROR

Error Creating Window Layout

File "string"

line 18

in module

Error creating Window layout

Your row is not an iterable (e.g a list)

Instead of a list, the type found was <class ‘PySimpleGUI PySimpleGUI Radio

The offensive row =

PySimpleGULPySimpleGUI Radio object at Oxb71dd28c>

This item will be stripped from your layout.

And this is my code (now):


import PySimpleGUI as pg

#Sets the theme to "Tan"

pg.theme("Tan")

#Creates the layout

layout = [[pg.Text("1. Zahl:"), pg.Input()],
    pg.Radio("+", "action"),
    pg.Radio("-", "action"),
    pg.Radio("*", "action"),
    pg.Radio("/", "action")]
#Creates the window

window = pg.Window("LittleCalc", layout, element_justification="c", no_titlebar=False,grab_anywhere=True,size=(400,400))
window.read()

#Interact with the window

while True:
    event, values = window.read(timeout=0.1)

Knows anyone where the problem is? Thanks.
Oh, and sorry for my bad English.

Asked By: pauljako

||

Answers:

Hi at your layout you need to also get other items into square bracket as well like below;

layout = [[pg.Text("1. Zahl:"), pg.Input()],[pg.Radio("+", "action")],[pg.Radio("-", "action")], [pg.Radio("*", "action")],[pg.Radio("/", "action")]]

#this part tells where is the problem

Error creating Window layout

#this should give hint about there might be wrong definition

Your row is not an iterable (e.g a list)

#here you can identify its expecting a list

Instead of a list, the type found was <class 'PySimpleGUI PySimpleGUI Radio
Answered By: Lanre

each member of your layout must be a list object.
in your code first layout member is a list but the other members are not.

Answered By: hofe
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.