[英]Using PySimpleGUI to divide the window in columns gives an error
我正試圖構建一個顯示兩列的GUi:一列將具有所有輸入字段和列表框,第二列將顯示pandas dataframe
一些數據。
我認為使用Frames
進行此操作是一個好主意,但是在嘗試創建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_')]])]
結果:
TypeError:*之后的AddRow()參數必須是可迭代的,而不是Frame
如何解決這個問題?
我在想是否有可能先使用Frame
定義列,然后將這些列放入layout
的定義中?
您必須使用[[ ]]
layout = [[
]]
外部[ ]
表示所有數據,內部[ ]
表示第一行-即使您只需要一行。
工作示例:
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.