我正在用PySimpleGui为我的python脚本制作一个简单的gui,并输入了一个问题。每次我想在InputCombo列表中添加新的整数时,我都无法访问新的整数
我写了一个基本脚本来展示:
import PySimpleGUI as sg
things=["a","b"]
layout=[[sg.Input(key="-input-",size=(10,1)),sg.Button("add",key="-add-")],
[sg.InputCombo(things,key="-combo-"),sg.Button("write")],
[sg.Text("",key="-output-"),sg.Button("Quit")]]
window=sg.Window("Name",layout,size=(200,200))
while True:
event,values=window.read()
if event==sg.WINDOW_CLOSED or event=="Quit":
break
if event=="add":
things.append(values["-input"])
if event=="write":
window["-output-"].update(values["-combo-"])
我有一张“东西”的清单。如果在inputfield中写入内容,我可以添加一个新值。通过“添加”按钮,我将值添加到我的“物品”列表中。通过InputCombo,我可以访问列表中的V值,例如“a”和“b”。如果我选择“a”或“b”并按“写入”,文本字段将更新并写入“a”或“b”。但是在InputCombo中,我不能选择值,这是我后来添加的。 有人知道我怎样才能把事情做好吗
调用
sg.InputCombo
的方法update(values=things)
来更新新值修订守则
相关问题 更多 >
编程相关推荐