Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use ParamSpec from typing_extensions
  • Loading branch information
insolor committed Nov 24, 2023
commit 1134c150cd3be6e5aaba299c0fd5eb6b9bd730b4
10 changes: 7 additions & 3 deletions async_tkinter_loop/async_tkinter_loop.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import _tkinter
import asyncio
import tkinter
from functools import wraps
from tkinter import TclError
from typing import Any, Callable, Coroutine

import _tkinter
from tkinter import TclError
from typing_extensions import ParamSpec


async def main_loop(root: tkinter.Tk) -> None:
Expand Down Expand Up @@ -48,7 +49,10 @@ def async_mainloop(root: tkinter.Tk) -> None:
get_event_loop().run_until_complete(main_loop(root))


def async_handler(async_function: Callable[..., Coroutine[Any, Any, None]], *args, **kwargs) -> Callable[..., None]:
P = ParamSpec("P")


def async_handler(async_function: Callable[P, Coroutine[Any, Any, None]], *args, **kwargs) -> Callable[P, None]:
"""
A helper function which allows to use async functions as command handlers (e.g. button click handlers) or event
handlers.
Expand Down