简体   繁体   中英

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

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 (eg 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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM