I wonder what does the parameter enable_events
, do for a button (sg.Button
).
Indeed, when there is a button in a code, it is always sending an event in the .read()
.
You don't need to specify enable_events=True
AND even if you specify enable_events=False
then button still sends an event.
Furthermore, in the reference of PysimpleGUI it is written that the default value of enable_events
is False
. Do anyone knows what is this about ?
Thank you
sg.Button
enable_events
Turns on the element specific events. If this button is a target, should it generate an event when filled in
Example Code
import PySimpleGUI as sg
layout = [
[sg.Input(key='-IN-'), sg.FileBrowse(target="Submit")],
[sg.Button("Submit", enable_events=True)],
]
window = sg.Window("Title", layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
print(event, values)
window.close()
Note: Most of time, we don't need to use this options enable_events=True
.