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

Method timer_start

PySimpleGUI/PySimpleGUI.py:12517–12544  ·  view source on GitHub ↗

Starts a timer that gnerates Timer Events. Time can be specified as an integer number of milliseconds or a string format "H:M:S" The default is to repeat the timer events until timer is stopped. You can provide your own key or a default key will be used. The default

(self, frequency_ms, key=EVENT_TIMER, repeating=True)

Source from the content-addressed store, hash-verified

12515
12516
12517 def timer_start(self, frequency_ms, key=EVENT_TIMER, repeating=True):
12518 """
12519 Starts a timer that gnerates Timer Events.
12520 Time can be specified as an integer number of milliseconds or a string format "H:M:S"
12521 The default is to repeat the timer events until timer is stopped.
12522 You can provide your own key or a default key will be used. The default key is defined
12523 with the constants EVENT_TIMER or TIMER_KEY. They both equal the same value.
12524 The values dictionary will contain the timer ID that is returned from this function.
12525
12526 :param frequency_ms: How often to generate timer events in milliseconds or a string "HH:MM:SS". HH, MM, SS each can be any length of chars
12527 :type frequency_ms: None | int | str
12528 :param key: Key to be returned as the timer event
12529 :type key: str | int | tuple | object
12530 :param repeating: If True then repeat timer events until timer is explicitly stopped
12531 :type repeating: bool
12532 :return: Timer ID for the timer or None if error
12533 :rtype: int | None
12534 """
12535 if isinstance(frequency_ms, str):
12536 try:
12537 hour, min, sec = self._parse_h_m_s(frequency_ms)
12538 frequency_ms = (hour * 3600 + min * 60 + sec) * 1000
12539 except Exception as e:
12540 popup_error_with_traceback('Error in H:M:S string', f'Error in H:M:S string = {frequency_ms}', e)
12541 return None
12542
12543 timer = _TimerPeriodic(self, frequency_ms=frequency_ms, key=key, repeating=repeating)
12544 return timer.id
12545
12546 def timer_stop(self, timer_id):
12547 """

Callers 5

mainFunction · 0.95
finalizeMethod · 0.95
_create_main_windowFunction · 0.95
mainFunction · 0.80
mainFunction · 0.80

Calls 3

_parse_h_m_sMethod · 0.95
_TimerPeriodicClass · 0.85

Tested by

no test coverage detected