FreeSimpleGUI icon indicating copy to clipboard operation
FreeSimpleGUI copied to clipboard

SUPPRESS_RAISE_KEY_ERRORS isn't honored

Open deajan opened this issue 9 months ago • 2 comments

As it says, setting the following still does show the FreeSimpleGUI error window, preventing handling KeyErrors from program.

    sg.set_options(
        suppress_raise_key_errors=True,
        suppress_error_popups=True,
        suppress_key_guessing=True,
    )

deajan avatar Feb 12 '25 15:02 deajan

Thanks for the report. Can you please provide a minimum reproducible example (so I can run it and reproduce) and/or if you have a full stacktrace, that would be helpful, too.

spyoungtech avatar Feb 12 '25 22:02 spyoungtech

Sure:

import FreeSimpleGUI as sg

sg.set_options(suppress_error_popups=True, suppress_key_guessing=True, suppress_raise_key_errors=True)

layout = [
    [sg.Text('Hello')],
    [sg.Button("trigger update to non existing key", key="-KEY-")],
    [sg.Button('OK')]
]

window = sg.Window('Test', layout)
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED:
        break
    if event == 'OK':
        print('OK')
        break
    if event == "-KEY-":
        window["nonexisting"].Update("This key does not exist")
window.close()

In the above example, I disabled all debugger options via set_options. In PySimpleGUI, this prevented the following window to show:

Image

Regardless of how I configure those options, I don't get the same result as PySimpleGUI v4.

deajan avatar Feb 14 '25 14:02 deajan