-1

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.

pauljako
  • 25
  • 5
  • Not familiar with the framework but the error tells you that you pass elements as rows when an iterable is expected in the rows you pass the radio buttons. Did you try to wrap all rows into a list like such: `[pg.Radio("+", "action")]`? You seem to do that for the first row but not the radio rows. Or are they all supposed to be one row? In that case perhaps try to put them all into one flat list. – ewz93 Aug 03 '22 at 15:57

2 Answers2

2

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.

hofe
  • 41
  • 2
1

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
Lanre
  • 340
  • 2
  • 6