繁体   English   中英

在 PySimpleGUI 中创建 window 布局时出现错误“您的行不是可迭代的(例如列表)”

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

我想用 PySimpleGUI 编写一个小型计算器,但是当我运行代码时它显示一个错误:

错误

创建 Window 布局时出错

文件“字符串”

第 18 行

在模块中

创建 Window 布局时出错

您的行不是可迭代的(例如列表)

找到的类型不是列表,而是 <class 'PySimpleGUI PySimpleGUI Radio

进攻排=

PySimpleGULPySimpleGUI Radio object at Oxb71dd28c>

此项目将从您的布局中删除。

这是我的代码(现在):


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)

有谁知道问题出在哪里? 谢谢。 哦,对不起我的英语不好。

布局的每个成员都必须是一个列表 object。 在您的代码中,第一个布局成员是一个列表,但其他成员不是。

嗨,在您的布局中,您还需要将其他项目放入方括号中,如下所示;

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

#这部分告诉你问题出在哪里

Error creating Window layout

#this 应该提示可能有错误的定义

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

#这里你可以识别它期待一个列表

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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