Home > Back-end >  Python SimpleGui multiple windows
Python SimpleGui multiple windows

Time:04-07

So basically i am using SimpleGUI and am able to create multiple windows, even with same content without errors. Now i just cannot get the events happening in the other windows that were created.

Is there any solution to create multiple windows and catch their events?

CodePudding user response:

You can use event viewer to navigate through:

Open Event Viewer by clicking the Start button Click Control Panel Click System and Security

Click Administrative Tools

Click Event Viewer

CodePudding user response:

For PySimpleGUI, instead of window.read, call sg.read_all_windows in event loop for multi-windows.

window, event, values = read_all_windows(timeout=None, timeout_key=TIMEOUT_KEY)

Reads all windows that are "active" when the call is made. "Active" means that it's been finalized or read. If a window has not been finalized then it will not be considered an "active window"

If any of the active windows returns a value then the window and its event and values are returned.

If no windows are open, then the value (None, WIN_CLOSED, None) will be returned Since WIN_CLOSED is None, it means (None, None, None) is what's returned when no windows remain opened

  • Related