Execution#
tk_execute#
- tk_async_execute.utils.tk_execute(method: Callable, *args, **kwargs)#
Allows thread-safe execution of tkinter methods.
- Parameters:
method (Callable) – A tkinter widget method. Methods that are not from tkinter widgets, should be called directly without this function.
args (Any) – Positional arguments to pass to
methodkwargs (Any) – Keyword arguments to pass to
method
async_execute#
- tk_async_execute.utils.async_execute(coro: Coroutine, wait: bool = True, visible: bool = True, pop_up: bool = False, callback: Callable | None = None, master: Any | None = None)#
Executes a coroutine inside asyncio event loop.
Call this from tkinter callbacks.
- Parameters:
coro (Coroutine) – The coro to run.
wait (Optional[bool]) –
Wait until the execution of
corohas completed, before returning from this function. Defaults to True.WARNING If multiple executions are happening at once, due to the way tkinter’s event loop works, this will wait for all executions to finish before returning from this function in the LIFO manner (last execution will be exited first).
visible (Optional[bool]) – Show the execution progress through a new window. Defaults to True.
pop_up (Optional[bool]) – If True, all other windows will be blocked from interactions, until the execution of
corois complete. Defaults to False.callback (Optional[Callable]) – Callback function to call with result afer coro has finished. Defaults to None.
master (Any) – The parent tkinter widget.
- Returns:
The progress TopLevel window responsible for
coroexecution.- Return type:
- Raises:
Exception – Exception that occurred in
coro(if it ocurred). Only raised ifwaitis True.