Dec-08-2020, 07:34 AM
(Dec-07-2020, 09:35 PM)deanhystad Wrote: I don't see how this could work.
if event == "Help": window_help.read() if event == "Cancel" or event == sg.WIN_CLOSED: breakTo get to the "break" event has to equal "Help" and at the same time equal "Cancel" or sg.WIN_CLOSED. In you while loop you read one event at a time and process one event at a time.
You should also use elif to limit the code executed for each loop.
while True: event, values = window.read() if event == sg.WIN_CLOSED or event == 'Exit': break if event == 'Convert': # Don't need elif here because of break seq=values['-IN-'] rc= reverseComplement(seq) window['-OUTPUT-'].update(rc) elif event == "Help": window_help.read() elif event == "Cancel" or event == sg.WIN_CLOSED: window_help.close()
Thank you for your reply. I added the second if statement (below) with the reasoning that it would only apply to the "Help" window. So if "Help" is pressed, then a new window pop ups, with its own new event and if statement. That's how I used nested if statements before, so I thought it also worked like that in an event loop?
if event == "Help": window_help.read() if event == "Cancel" or event == sg.WIN_CLOSED: breakThanks for rewriting the code. However, I still cannot close the Help window using the "Cancel" button. Also it is not possible to press Help twice. Any ideas how to solve this?