SimpleGuy_
SimpleGuy_

Reputation: 453

Update default value of a Combo

I would like to change the default value of the combo when I press the button,Is it possible to do so ?

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()

Upvotes: 3

Views: 4156

Answers (1)

SinerYe
SinerYe

Reputation: 116

wnd.find_element("board2").update(value="Example3")

If value is in values ["Example1","Example2","Example3"], DefaultValue will also change to value. But value is not in values, DefaultValue will not change.

Upvotes: 4

Related Questions