async-tkinter-loop 0.10.3__tar.gz → 0.10.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/PKG-INFO +7 -7
- {async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/README.md +1 -1
- {async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/async_tkinter_loop/async_tkinter_loop.py +16 -5
- {async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/pyproject.toml +13 -12
- {async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/LICENSE +0 -0
- {async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/async_tkinter_loop/__init__.py +0 -0
- {async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/async_tkinter_loop/mixins.py +0 -0
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: async-tkinter-loop
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.5
|
|
4
4
|
Summary: Asynchronous mainloop implementation for tkinter
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: tkinter,async,async-await,asyncio,aiohttp
|
|
8
8
|
Author: insolor
|
|
9
9
|
Author-email: insolor@gmail.com
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.11,<4.0
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
21
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
22
|
Provides-Extra: examples
|
|
23
|
-
Requires-Dist: Pillow (>=
|
|
24
|
-
Requires-Dist: customtkinter (>=5
|
|
25
|
-
Requires-Dist: httpx (>=0.23.1,<0.
|
|
23
|
+
Requires-Dist: Pillow (>=13.0.0,<14.0.0) ; extra == "examples"
|
|
24
|
+
Requires-Dist: customtkinter (>=5,<7) ; extra == "examples"
|
|
25
|
+
Requires-Dist: httpx (>=0.23.1,<0.30.0) ; extra == "examples"
|
|
26
26
|
Requires-Dist: typing-extensions
|
|
27
27
|
Project-URL: Documentation, https://insolor.github.io/async-tkinter-loop/
|
|
28
28
|
Project-URL: Homepage, https://github.com/insolor/async-tkinter-loop
|
|
@@ -63,7 +63,7 @@ pip install async-tkinter-loop
|
|
|
63
63
|
```
|
|
64
64
|
or
|
|
65
65
|
```
|
|
66
|
-
pip install async-tkinter-loop[examples]
|
|
66
|
+
pip install "async-tkinter-loop[examples]"
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
- `[examples]` part is needed to install optional dependencies (such as `httpx` and `pillow`) to run some of the
|
|
@@ -32,7 +32,7 @@ pip install async-tkinter-loop
|
|
|
32
32
|
```
|
|
33
33
|
or
|
|
34
34
|
```
|
|
35
|
-
pip install async-tkinter-loop[examples]
|
|
35
|
+
pip install "async-tkinter-loop[examples]"
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
- `[examples]` part is needed to install optional dependencies (such as `httpx` and `pillow`) to run some of the
|
{async_tkinter_loop-0.10.3 → async_tkinter_loop-0.10.5}/async_tkinter_loop/async_tkinter_loop.py
RENAMED
|
@@ -7,6 +7,8 @@ from typing import Any
|
|
|
7
7
|
|
|
8
8
|
from typing_extensions import ParamSpec
|
|
9
9
|
|
|
10
|
+
_MAX_EVENTS_PER_ITERATION = 64
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
async def main_loop(root: tk.Tk) -> None:
|
|
12
14
|
"""
|
|
@@ -17,16 +19,20 @@ async def main_loop(root: tk.Tk) -> None:
|
|
|
17
19
|
root: tkinter root window object
|
|
18
20
|
"""
|
|
19
21
|
while True:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
for _ in range(_MAX_EVENTS_PER_ITERATION):
|
|
23
|
+
if not root.dooneevent(_tkinter.DONT_WAIT):
|
|
24
|
+
delay = _tkinter.getbusywaitinterval() / 1000
|
|
25
|
+
break
|
|
26
|
+
else:
|
|
27
|
+
# Tk may still have pending events. Give asyncio a turn before continuing.
|
|
28
|
+
delay = 0
|
|
23
29
|
|
|
24
30
|
try:
|
|
25
31
|
root.winfo_exists() # Will throw TclError if the main window is destroyed
|
|
26
32
|
except tk.TclError:
|
|
27
33
|
break
|
|
28
34
|
|
|
29
|
-
await asyncio.sleep(
|
|
35
|
+
await asyncio.sleep(delay)
|
|
30
36
|
|
|
31
37
|
|
|
32
38
|
def get_event_loop() -> asyncio.AbstractEventLoop:
|
|
@@ -53,6 +59,8 @@ def async_mainloop(root: tk.Tk, event_loop: asyncio.AbstractEventLoop | None = N
|
|
|
53
59
|
|
|
54
60
|
P = ParamSpec("P")
|
|
55
61
|
|
|
62
|
+
_tasks = set()
|
|
63
|
+
|
|
56
64
|
|
|
57
65
|
def async_handler(
|
|
58
66
|
async_function: Callable[P, Coroutine[Any, Any, None]],
|
|
@@ -106,9 +114,12 @@ def async_handler(
|
|
|
106
114
|
button = tk.Button("Press me", command=some_async_function)
|
|
107
115
|
```
|
|
108
116
|
"""
|
|
117
|
+
|
|
109
118
|
@wraps(async_function)
|
|
110
119
|
def wrapper(*handler_args) -> None:
|
|
111
120
|
loop = event_loop or get_event_loop()
|
|
112
|
-
loop.create_task(async_function(*handler_args, *args, **kwargs))
|
|
121
|
+
task = loop.create_task(async_function(*handler_args, *args, **kwargs))
|
|
122
|
+
_tasks.add(task)
|
|
123
|
+
task.add_done_callback(_tasks.discard)
|
|
113
124
|
|
|
114
125
|
return wrapper
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "async-tkinter-loop"
|
|
3
|
-
version = "0.10.
|
|
3
|
+
version = "0.10.5"
|
|
4
4
|
description = "Asynchronous mainloop implementation for tkinter"
|
|
5
5
|
authors = ["insolor <insolor@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -12,28 +12,27 @@ keywords = ["tkinter", "async", "async-await", "asyncio", "aiohttp"]
|
|
|
12
12
|
classifiers = [
|
|
13
13
|
"Development Status :: 4 - Beta",
|
|
14
14
|
"Operating System :: OS Independent",
|
|
15
|
-
"License :: OSI Approved :: MIT License",
|
|
16
15
|
"Intended Audience :: Developers",
|
|
17
16
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
18
17
|
]
|
|
19
18
|
|
|
20
19
|
[tool.poetry.dependencies]
|
|
21
|
-
python = "^3.
|
|
22
|
-
Pillow = {version = ">=
|
|
23
|
-
httpx = {version = ">=0.23.1,<0.
|
|
24
|
-
customtkinter = {version = "
|
|
20
|
+
python = "^3.11"
|
|
21
|
+
Pillow = {version = ">=13.0.0,<14.0.0", optional = true}
|
|
22
|
+
httpx = {version = ">=0.23.1,<0.30.0", optional = true}
|
|
23
|
+
customtkinter = {version = ">=5,<7", optional = true}
|
|
25
24
|
typing-extensions = "*"
|
|
26
25
|
|
|
27
26
|
[tool.poetry.group.dev.dependencies]
|
|
28
|
-
pytest = ">=7.4,<
|
|
27
|
+
pytest = ">=7.4,<10.0"
|
|
29
28
|
pytest-cov = ">=4.1,<8.0"
|
|
30
29
|
pytest-timeout = "^2.0.1"
|
|
31
|
-
ruff = ">=0.4.7,<0.
|
|
32
|
-
customtkinter = "
|
|
30
|
+
ruff = ">=0.4.7,<0.18.0"
|
|
31
|
+
customtkinter = ">=5.2.1,<7.0.0"
|
|
33
32
|
|
|
34
33
|
[tool.poetry.group.docs.dependencies]
|
|
35
34
|
mkdocs = "^1.5.2"
|
|
36
|
-
mkdocstrings = {extras = ["python"], version = ">=0.22,<
|
|
35
|
+
mkdocstrings = {extras = ["python"], version = ">=0.22,<1.1"}
|
|
37
36
|
mkdocs-material = "^9.2.5"
|
|
38
37
|
|
|
39
38
|
[tool.poetry.extras]
|
|
@@ -44,7 +43,7 @@ requires = ["poetry-core>=1.0.0"]
|
|
|
44
43
|
build-backend = "poetry.core.masonry.api"
|
|
45
44
|
|
|
46
45
|
[tool.ruff]
|
|
47
|
-
target-version = "
|
|
46
|
+
target-version = "py311"
|
|
48
47
|
line-length = 120
|
|
49
48
|
|
|
50
49
|
[tool.ruff.lint]
|
|
@@ -53,6 +52,8 @@ ignore = [
|
|
|
53
52
|
"D", # Warning about docstrings are suppressed for now
|
|
54
53
|
"ANN002",
|
|
55
54
|
"ANN003",
|
|
55
|
+
"COM812", # Conflicts with the formatter
|
|
56
|
+
"CPY001",
|
|
56
57
|
]
|
|
57
58
|
fixable = ["ALL"]
|
|
58
59
|
|
|
@@ -72,4 +73,4 @@ fixable = ["ALL"]
|
|
|
72
73
|
"PL",
|
|
73
74
|
"INP001",
|
|
74
75
|
"RUF006",
|
|
75
|
-
]
|
|
76
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|