Skip to content
Advertisement

TypeError when adding multiple widgets to layout using SimpleGui

(answered] I’m learning SimpleGui and when adding multiple widgets to the layout the system gives me a TypeError. Here is my code for the layout

layout = [
[sg.Text("I have no idea what i am doing")]

[sg.Text("i wanna make games and stuff")]
]

I’m using version 3.10.0 of python if that helps

Advertisement

Answer

You’re missing a comma between your two lists:

layout = [
    [sg.Text("I have no idea what i am doing")],
    [sg.Text("i wanna make games and stuff")]
]

The error you get (TypeError: list indices must be integers or slices, not Text) is because the python interpreter thinks you’re trying to index into the first list with your second list.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement