2

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()
SimpleGuy_
  • 443
  • 5
  • 12

1 Answers1

3
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.

SinerYe
  • 106
  • 3
  • Bro could you please answer my question @ https://stackoverflow.com/questions/69504059/obtain-default-value-from-a-combo I think you will be able to do it,Please :) – SimpleGuy_ Oct 09 '21 at 05:41