Call your function that will take a long time to execute. When it's complete, send an event specified by the end_key. Starts a thread on your behalf. This is a way for you to "ease into" threading without learning the details of threading. Your function wi
(self, func, end_key=None)
| 12367 | return grab |
| 12368 | |
| 12369 | def start_thread(self, func, end_key=None): |
| 12370 | """ |
| 12371 | Call your function that will take a long time to execute. When it's complete, send an event |
| 12372 | specified by the end_key. |
| 12373 | |
| 12374 | Starts a thread on your behalf. |
| 12375 | |
| 12376 | This is a way for you to "ease into" threading without learning the details of threading. |
| 12377 | Your function will run, and when it returns 2 things will happen: |
| 12378 | 1. The value you provide for end_key will be returned to you when you call window.read() |
| 12379 | 2. If your function returns a value, then the value returned will also be included in your windows.read call in the values dictionary |
| 12380 | |
| 12381 | IMPORTANT - This method uses THREADS... this means you CANNOT make any PySimpleGUI calls from |
| 12382 | the function you provide with the exception of one function, Window.write_event_value. |
| 12383 | |
| 12384 | :param func: A lambda or a function name with no parms |
| 12385 | :type func: Any |
| 12386 | :param end_key: Optional key that will be generated when the function returns |
| 12387 | :type end_key: (Any | None) |
| 12388 | :return: The id of the thread |
| 12389 | :rtype: threading.Thread |
| 12390 | """ |
| 12391 | |
| 12392 | thread = threading.Thread(target=_long_func_thread, args=(self, end_key, func), daemon=True) |
| 12393 | thread.start() |
| 12394 | return thread |
| 12395 | |
| 12396 | @property |
| 12397 | def key_dict(self): |
no test coverage detected