MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / read

Method read

PySimpleGUI/PySimpleGUI.py:10586–10659  ·  view source on GitHub ↗

THE biggest deal method in the Window class! This is how you get all of your data from your Window. Pass in a timeout (in milliseconds) to wait for a maximum of timeout milliseconds. Will return timeout_key if no other GUI events happen first. :param timeout

(self, timeout=None, timeout_key=TIMEOUT_KEY, close=False)

Source from the content-addressed store, hash-verified

10584
10585 # @_timeit_summary
10586 def read(self, timeout=None, timeout_key=TIMEOUT_KEY, close=False):
10587 """
10588 THE biggest deal method in the Window class! This is how you get all of your data from your Window.
10589 Pass in a timeout (in milliseconds) to wait for a maximum of timeout milliseconds. Will return timeout_key
10590 if no other GUI events happen first.
10591
10592 :param timeout: Milliseconds to wait until the Read will return IF no other GUI events happen first
10593 :type timeout: int | None
10594 :param timeout_key: The value that will be returned from the call if the timer expired
10595 :type timeout_key: (Any)
10596 :param close: if True the window will be closed prior to returning
10597 :type close: (bool)
10598 :return: (event, values)
10599 :rtype: Tuple[(Any), Dict[Any, Any], List[Any], None]
10600 """
10601
10602 if Window._floating_debug_window_build_needed is True:
10603 Window._floating_debug_window_build_needed = False
10604 _Debugger.debugger._build_floating_window()
10605
10606 if Window._main_debug_window_build_needed is True:
10607 Window._main_debug_window_build_needed = False
10608 _Debugger.debugger._build_main_debugger_window()
10609
10610 # ensure called only 1 time through a single read cycle
10611 if not Window._read_call_from_debugger:
10612 _refresh_debugger()
10613
10614 # if the user has not added timeout and a debug window is open, then set a timeout for them so the debugger continuously refreshes
10615 if _debugger_window_is_open() and not Window._read_call_from_debugger:
10616 if timeout is None or timeout > 3000:
10617 timeout = 200
10618
10619 self._right_click_menu_element = None
10620
10621 while True:
10622 Window._root_running_mainloop = self.TKroot
10623 results = self._read(timeout=timeout, timeout_key=timeout_key)
10624 if results is not None:
10625 if results[0] == DEFAULT_WINDOW_SNAPSHOT_KEY:
10626 self.save_window_screenshot_to_disk()
10627 popup_quick_message('Saved window screenshot to disk', background_color='#1c1e23', text_color='white', keep_on_top=True, font='_ 30')
10628 continue
10629 # Post processing for Calendar Chooser Button
10630 try:
10631 if results[0] == timeout_key: # if a timeout, then not a calendar button
10632 break
10633 elem = self.find_element(results[0], silent_on_error=True) # get the element that caused the event
10634 if elem.Type == ELEM_TYPE_BUTTON:
10635 if elem.BType == BUTTON_TYPE_CALENDAR_CHOOSER:
10636 if self._calendar_chooser_button_clicked(elem): # returns True if should break out
10637 # results[0] = self.LastButtonClicked
10638 results = self.ReturnValues
10639 break
10640 else:
10641 continue
10642 break
10643 except:

Callers 15

mainFunction · 0.95
mainFunction · 0.95
ChatBotWithHistoryFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
TableSimulationFunction · 0.95
mainFunction · 0.95
HowDoIFunction · 0.95
mainFunction · 0.95
HashGeneratorGUIFunction · 0.95
choose_themeFunction · 0.95

Calls 12

_readMethod · 0.95
find_elementMethod · 0.95
closeMethod · 0.95
_refresh_debuggerFunction · 0.85
_debugger_window_is_openFunction · 0.85
popup_quick_messageFunction · 0.85
dict_to_stringFunction · 0.85
getMethod · 0.45

Tested by 1

test_menusFunction · 0.76