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)
| 10660 | |
| 10661 | # @_timeit |
| 10662 | def _read(self, timeout=None, timeout_key=TIMEOUT_KEY): |
| 10663 | """ |
| 10664 | THE biggest deal method in the Window class! This is how you get all of your data from your Window. |
| 10665 | Pass in a timeout (in milliseconds) to wait for a maximum of timeout milliseconds. Will return timeout_key |
| 10666 | if no other GUI events happen first. |
| 10667 | |
| 10668 | :param timeout: Milliseconds to wait until the Read will return IF no other GUI events happen first |
| 10669 | :type timeout: (int) |
| 10670 | :param timeout_key: The value that will be returned from the call if the timer expired |
| 10671 | :type timeout_key: (Any)` |
| 10672 | :return: (event, values) (event or timeout_key or None, Dictionary of values or List of values from all elements in the Window) |
| 10673 | :rtype: Tuple[(Any), Dict[Any, Any], List[Any], None] |
| 10674 | """ |
| 10675 | |
| 10676 | # if there are events in the thread event queue, then return those events before doing anything else. |
| 10677 | if self._queued_thread_event_available(): |
| 10678 | self.ReturnValues = results = _BuildResults(self, False, self) |
| 10679 | return results |
| 10680 | |
| 10681 | if self.finalize_in_progress and self.auto_close_timer_needs_starting: |
| 10682 | self._start_autoclose_timer() |
| 10683 | self.auto_close_timer_needs_starting = False |
| 10684 | |
| 10685 | timeout = int(timeout) if timeout is not None else None |
| 10686 | if timeout == 0: # timeout of zero runs the old readnonblocking |
| 10687 | event, values = self._ReadNonBlocking() |
| 10688 | if event is None: |
| 10689 | event = timeout_key |
| 10690 | if values is None: |
| 10691 | event = None |
| 10692 | return event, values # make event None if values was None and return |
| 10693 | # Read with a timeout |
| 10694 | self.Timeout = timeout |
| 10695 | self.TimeoutKey = timeout_key |
| 10696 | self.NonBlocking = False |
| 10697 | if self.TKrootDestroyed: |
| 10698 | self.read_closed_window_count += 1 |
| 10699 | if self.read_closed_window_count > 100: |
| 10700 | popup_error_with_traceback('Trying to read a closed window', 'You have tried 100 times to read a closed window.', 'You need to add a check for event == WIN_CLOSED',) |
| 10701 | return None, None |
| 10702 | if not self.Shown: |
| 10703 | self._Show() |
| 10704 | else: |
| 10705 | # if already have a button waiting, the return previously built results |
| 10706 | if self.LastButtonClicked is not None and not self.LastButtonClickedWasRealtime: |
| 10707 | results = _BuildResults(self, False, self) |
| 10708 | self.LastButtonClicked = None |
| 10709 | return results |
| 10710 | InitializeResults(self) |
| 10711 | |
| 10712 | if self._queued_thread_event_available(): |
| 10713 | self.ReturnValues = results = _BuildResults(self, False, self) |
| 10714 | return results |
| 10715 | |
| 10716 | # if the last button clicked was realtime, emulate a read non-blocking |
| 10717 | # the idea is to quickly return realtime buttons without any blocks until released |
| 10718 | if self.LastButtonClickedWasRealtime: |
| 10719 | # clear the realtime flag if the element is not a button element (for example a graph element that is dragging) |
no test coverage detected