Reputation: 521
I am tring to construct a GUi that would display two columns:
one column would have all the input fields and listboxes, the second column would display some data from pandas dataframe
.
I thought it would be a good idea to do this using Frames
, but I am running into an error when trying to create a Frame
:
layout = [sg.Frame('Input data',[[
sg.Text('Input:'),
sg.Input(do_not_clear=False),
sg.Button('Read'), sg.Exit(),
sg.Text('Alternatives:'),
sg.Listbox(values=('alternatives...', ''), size=(30, 2), key='_LISTBOX_')]])]
Result:
TypeError: AddRow() argument after * must be an iterable, not Frame
How to fix this?
I am thinking if it is possible to define columns first, using Frame
, and then putting the columns into the definition of layout
?
Upvotes: 2
Views: 10784
Reputation: 142641
You have to use [[ ]]
layout = [[
]]
External [ ]
means all data, internal [ ]
means first row - even if you need only one row.
Working example:
import PySimpleGUI as sg
layout = [[
sg.Frame('Input data',[[
sg.Text('Input:'),
sg.Input(do_not_clear=False),
sg.Button('Read'), sg.Exit(),
sg.Text('Alternatives:'),
sg.Listbox(values=('alternatives...', ''), size=(30, 2), key='_LISTBOX_')
]])
]]
window = sg.Window('App', layout)
event, values = window.Read()
window.Close()
Upvotes: 5