I want to have a select all checkbox in my PySimpleGUI. When the select all checkbox is selected, all other checkboxes should change to True, and if any other box is unchecked, the select all checkbox should change to false state?
I can do it through button clicks, but I couldn't find a way to update checkboxes based on values selected in an another checkbox?
import PySimpleGUI as sg
layout = [
[sg.Checkbox ('select all', key = 'checkbox')],
[sg.Checkbox ('value 1', key='check_value1')],
[sg.Checkbox ('value 2',key='check_value2')],
[sg.Button ('ON', key = 'ON')],
[sg.Button ('OFF', key = 'OFF')]
]
window = sg.Window ('Sample GUI', layout) .Finalize ()
while True: # Event Loop
event,values=window.read()
if event in (None, 'Exit'):
break
elif event == 'ON':
window ['checkbox']. Update (value = True)
elif event == 'OFF':
window ['checkbox']. Update (value = False)
print(event,values)
window.close ()
Is there any way to implement this?