'How to have independent tabs in pysimplegui

I am creating a GUI that can launch executables. The GUI has several tabs, one for each executable. Each tab also has its own OK button. When OK is pressed, I want to launch the exe for that tab.

The problem is that when I inspect values, I get a dict for all the elements from all the tabs. How can I get values for only one tab?

layout1 = [[sg.Checkbox('CK option', key='ck1')],
           [sg.Button('Run myexe1')]]

layout2 = [[sg.Checkbox('CK option', key='ck2')],
           [sg.Button('Run myexe2')]]

layout = [[sg.TabGroup([[sg.Tab('tab1', layout1), 
            sg.Tab('tab2', layout2)]])]]

window = sg.Window('Application Runner', layout)

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED:
        break
    elif event == 'Run myexe1': 
        print('You entered ', values, event) # Problem is - I get ck1 and ck2. Want to get only ck1
    elif event == 'Run myexe2': 
        print('You entered ', values, event) # Problem is - I get ck1 and ck2. Want to get only ck2


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source