async-tkinter-loop 0.10.2__tar.gz → 0.10.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: async-tkinter-loop
3
- Version: 0.10.2
3
+ Version: 0.10.4
4
4
  Summary: Asynchronous mainloop implementation for tkinter
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -20,8 +20,8 @@ Classifier: Programming Language :: Python :: 3.13
20
20
  Classifier: Programming Language :: Python :: 3.14
21
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
22
  Provides-Extra: examples
23
- Requires-Dist: Pillow (>=10.3.0,<12.0.0) ; extra == "examples"
24
- Requires-Dist: customtkinter (>=5.2.1,<6.0.0) ; extra == "examples"
23
+ Requires-Dist: Pillow (>=10.3.0,<13.0.0) ; extra == "examples"
24
+ Requires-Dist: customtkinter (>=5,<6) ; extra == "examples"
25
25
  Requires-Dist: httpx (>=0.23.1,<0.29.0) ; extra == "examples"
26
26
  Requires-Dist: typing-extensions
27
27
  Project-URL: Documentation, https://insolor.github.io/async-tkinter-loop/
@@ -53,6 +53,8 @@ def async_mainloop(root: tk.Tk, event_loop: asyncio.AbstractEventLoop | None = N
53
53
 
54
54
  P = ParamSpec("P")
55
55
 
56
+ _tasks = set()
57
+
56
58
 
57
59
  def async_handler(
58
60
  async_function: Callable[P, Coroutine[Any, Any, None]],
@@ -106,9 +108,12 @@ def async_handler(
106
108
  button = tk.Button("Press me", command=some_async_function)
107
109
  ```
108
110
  """
111
+
109
112
  @wraps(async_function)
110
113
  def wrapper(*handler_args) -> None:
111
114
  loop = event_loop or get_event_loop()
112
- loop.create_task(async_function(*handler_args, *args, **kwargs))
115
+ task = loop.create_task(async_function(*handler_args, *args, **kwargs))
116
+ _tasks.add(task)
117
+ task.add_done_callback(_tasks.discard)
113
118
 
114
119
  return wrapper
@@ -1,3 +1,4 @@
1
+ import asyncio
1
2
  import sys
2
3
  import tkinter as tk
3
4
 
@@ -5,12 +6,12 @@ from async_tkinter_loop import async_mainloop
5
6
 
6
7
 
7
8
  class AsyncTk:
8
- def async_mainloop(self: tk.Tk) -> None:
9
- async_mainloop(self)
9
+ def async_mainloop(self: tk.Tk, event_loop: asyncio.AbstractEventLoop | None = None) -> None:
10
+ async_mainloop(self, event_loop=event_loop)
10
11
 
11
12
 
12
13
  class AsyncCTk(AsyncTk):
13
- def async_mainloop(self) -> None:
14
+ def async_mainloop(self, event_loop: asyncio.AbstractEventLoop | None = None) -> None:
14
15
  # Based on the code from CustomTkinter by Tom Schimansky
15
16
  # Source https://github.com/TomSchimansky/CustomTkinter/blob/d719950f80eb2768db96bd4cc627523e99603b1b/customtkinter/windows/ctk_tk.py#L155
16
17
  if not self._window_exists:
@@ -22,4 +23,4 @@ class AsyncCTk(AsyncTk):
22
23
 
23
24
  self._window_exists = True
24
25
 
25
- super().async_mainloop()
26
+ super().async_mainloop(event_loop=event_loop)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "async-tkinter-loop"
3
- version = "0.10.2"
3
+ version = "0.10.4"
4
4
  description = "Asynchronous mainloop implementation for tkinter"
5
5
  authors = ["insolor <insolor@gmail.com>"]
6
6
  license = "MIT"
@@ -19,21 +19,21 @@ classifiers = [
19
19
 
20
20
  [tool.poetry.dependencies]
21
21
  python = "^3.10"
22
- Pillow = {version = ">=10.3.0,<12.0.0", optional = true}
22
+ Pillow = {version = ">=10.3.0,<13.0.0", optional = true}
23
23
  httpx = {version = ">=0.23.1,<0.29.0", optional = true}
24
- customtkinter = {version = "^5.2.1", optional = true}
24
+ customtkinter = {version = ">=5,<6", optional = true}
25
25
  typing-extensions = "*"
26
26
 
27
27
  [tool.poetry.group.dev.dependencies]
28
- pytest = ">=7.4,<9.0"
28
+ pytest = ">=7.4,<10.0"
29
29
  pytest-cov = ">=4.1,<8.0"
30
30
  pytest-timeout = "^2.0.1"
31
- ruff = ">=0.4.7,<0.14.0"
31
+ ruff = ">=0.4.7,<0.16.0"
32
32
  customtkinter = "^5.2.1"
33
33
 
34
34
  [tool.poetry.group.docs.dependencies]
35
35
  mkdocs = "^1.5.2"
36
- mkdocstrings = {extras = ["python"], version = ">=0.22,<0.31"}
36
+ mkdocstrings = {extras = ["python"], version = ">=0.22,<1.1"}
37
37
  mkdocs-material = "^9.2.5"
38
38
 
39
39
  [tool.poetry.extras]
@@ -53,6 +53,7 @@ ignore = [
53
53
  "D", # Warning about docstrings are suppressed for now
54
54
  "ANN002",
55
55
  "ANN003",
56
+ "COM812", # Conflicts with the formatter
56
57
  ]
57
58
  fixable = ["ALL"]
58
59