MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / read_all_windows

Function read_all_windows

PySimpleGUI/PySimpleGUI.py:12737–12820  ·  view source on GitHub ↗

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

(timeout=None, timeout_key=TIMEOUT_KEY)

Source from the content-addressed store, hash-verified

12735
12736
12737def read_all_windows(timeout=None, timeout_key=TIMEOUT_KEY):
12738 """
12739 Reads all windows that are "active" when the call is made. "Active" means that it's been finalized or read.
12740 If a window has not been finalized then it will not be considered an "active window"
12741
12742 If any of the active windows returns a value then the window and its event and values
12743 are returned.
12744
12745 If no windows are open, then the value (None, WIN_CLOSED, None) will be returned
12746 Since WIN_CLOSED is None, it means (None, None, None) is what's returned when no windows remain opened
12747
12748 :param timeout: Time in milliseconds to delay before a returning a timeout event
12749 :type timeout: (int)
12750 :param timeout_key: Key to return when a timeout happens. Defaults to the standard TIMEOUT_KEY
12751 :type timeout_key: (Any)
12752 :return: A tuple with the (Window, event, values dictionary/list)
12753 :rtype: (Window, Any, Dict | List)
12754 """
12755
12756 if len(Window._active_windows) == 0:
12757 return None, WIN_CLOSED, None
12758
12759 # first see if any queued events are waiting for any of the windows
12760 for window in Window._active_windows.keys():
12761 if window._queued_thread_event_available():
12762 _BuildResults(window, False, window)
12763 event, values = window.ReturnValues
12764 return window, event, values
12765
12766 Window._root_running_mainloop = Window.hidden_master_root
12767 Window._timeout_key = timeout_key
12768
12769 if timeout == 0:
12770 window = list(Window._active_windows.keys())[Window._timeout_0_counter]
12771 event, values = window._ReadNonBlocking()
12772 if event is None:
12773 event = timeout_key
12774 if values is None:
12775 event = None
12776 Window._timeout_0_counter = (Window._timeout_0_counter + 1) % len(Window._active_windows)
12777 return window, event, values
12778
12779 Window._timeout_0_counter = 0 # reset value if not reading with timeout 0 so ready next time needed
12780
12781 # setup timeout timer
12782 if timeout != None:
12783 try:
12784 Window.hidden_master_root.after_cancel(Window._TKAfterID)
12785 del Window._TKAfterID
12786 except:
12787 pass
12788
12789 Window._TKAfterID = Window.hidden_master_root.after(timeout, _timeout_alarm_callback_hidden)
12790
12791 # ------------ Call Mainloop ------------
12792 Window._root_running_mainloop.mainloop()
12793
12794 try:

Callers

nothing calls this directly

Calls 4

_BuildResultsFunction · 0.85
_ReadNonBlockingMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected