更新组合的默认值
Update default value of a Combo
我想在按下按钮时更改组合的默认值,是否可以这样做?
from PySimpleGUI import *
layout=[[Combo(["Example1","Example2","Example3"],default_value='example2',key='board2')],[Button("Change")]]
wnd=Window("Test",layout)
event,values=wnd.read()
if event=="Change":
wnd.find_element["board2"].update(default_value="example3")
else:
wnd.close()
wnd.find_element("board2").update(value="Example3")
如果值在值 ["Example1","Example2","Example3"] 中,DefaultValue 也会更改为值。但是value不在values中,DefaultValue不会改变。
我想在按下按钮时更改组合的默认值,是否可以这样做?
from PySimpleGUI import *
layout=[[Combo(["Example1","Example2","Example3"],default_value='example2',key='board2')],[Button("Change")]]
wnd=Window("Test",layout)
event,values=wnd.read()
if event=="Change":
wnd.find_element["board2"].update(default_value="example3")
else:
wnd.close()
wnd.find_element("board2").update(value="Example3")
如果值在值 ["Example1","Example2","Example3"] 中,DefaultValue 也会更改为值。但是value不在values中,DefaultValue不会改变。